The US government was scrambling to end discriminatory employment and immigration policies on Thursday as the most sweeping gay rights breakthrough in recent legal history quickly began to make an impact.

Within hours of the supreme court ruling striking down the Defence of Marriage Act (Doma) as unconstitutional, many branches of the federal government including the Pentagon and State Department had issued statements saying they would immediately extend employee benefits to same-sex partners.

The Department of Homeland Security also announced it would begin reviewing immigration policies affecting thousands of mixed nationality gay couples.

Janet Napolitano, the homeland security secretary, said: "Working with our federal partners, including the Department of Justice, we will implement [Wednesday's] decision so that all married couples will be treated equally and fairly in the administration of our immigration laws."

The practical implications of the repeal of Doma are extensive. Marital status is relevant to more than 1,000 federal laws, ranging from personal finance to immigration. Gay couples in states that permit same-sex marriage will be able to file joint tax returns and access federal benefits. The Williams Institute estimates that there are about 114,100 legally married same-sex couples in the US.

Federal agencies such as the Internal Revenue Service will have to work out how they define marriage, particularly for people who marry in a state that permits same-sex unions but then move to a state that does not.

Anthony Infanti, a law professor at the University of Pittsburgh law school and specialist in tax law for gay people, said that the end of Doma would mean "confusion and chaos" until the government and federal agencies make clear how each will define marriage.

Gay couple Richard Kelley and Steven Jung celebrate with a kiss. Photograph: Krista Kennell/ZUMA Press/Corbis

Infanti said that overturning Doma "raises a real question" for agencies, as to whether they recognise a marriage because of where it took place or where the partners live: the "state of celebration" or the "place of residence".

The issue is further complicated in those states that do not allow gay marriage, but permit same-sex civil unions, such as Illinois and New Jersey. The IRS already recognises civil unions of heterosexual couples, and may extend those recognitions to same-sex couples.

In California, governor Jerry Brown seized on a separate supreme court ruling, which dismissed an appeal to uphold the state's Proposition 8 vote banning gay marriage. State officials instructed county clerks to begin issuing marriage licences to same sex couples as soon as a lower court ends a temporary ban on same-sex marriage, in place since Prop 8 passed in 2008.

The court said on Wednesday that the supreme court ruling would become official in 25 days. But there may be further legal moves to come, as the court said it might consider calls for a rehearing from supporters of Prop 8.

Opponents of Prop 8 believe the supreme court decision means same-sex marriage can now be permitted across California. Its supporters say the decision pertains to the two couples who had challenged the law, or at most, to the counties of Alameda and San Francisco.

That is likely to lead to more legal wrangling, as soon as a gay couple applies for a marriage licence in a county other than those two. However, the attorney acting on behalf of the Prop 8 supporters, Andy Pugno, declined to comment on Thursday and has not revealed if they intend to return to court.

The now-retired judge who made the original decision that overturned Prop 8, Vaughn Walker, said on Wednesday that there was no doubt in his mind that his ruling applied statewide. "But my mind doesn't control this," Walker told the San Jose Mercury News.

Any legal maneuvering could delay the restoration of gay marriage in California, but most analysts insist the arguments are weak and unlikely to stand. Vikram Amar, a law professor at UC Davis, who has previously suggested that Walker's injunction may only apply to the two couples who sued, conceded that argument had been defeated. "I think that train has left the station," Amar told the Mercury News.

Stuart Gaffney poses with his husband John Lewis as celebrations ensue in the Castro neighborhood of San Francisco. Photograph: Josh Edelson/AFP/Getty Images

In the meantime, the San Francisco gay community threw one of the biggest parties of the year on Wednesday. Thousands of people thronged the Castro neighborhood, at the heart of gay life in the city.

Businesses closed early and traffic was detoured away from the area as revellers danced into the night.

Some held banners celebrating the supreme court's decisions and handed out rainbow colored flags. One man held a banner saying: "Don't marry, be happy."

Malcolm Long was celerbrating with his partner Jonathan Price. He said: "This is one of the most important days in American history and it is amazing to live in a time when something like this can happen. I don't know if we will be married but knowing that we now have the option, it makes us equal. For the first time, our relationship can have the same legal standing as a heterosexual couple."

In New York, crowds celebrated outside the Stonewall Inn in West Village late into the night. Police were content to allow New York's strict ban on on-street drinking to go unenforced, standing by as hundreds of people gathered on the plaza outside the crucible of the gay rights movement in the US. It was at the Stonewall Inn, 44 years ago almost to the day, that a police raid led to riots that spawned the modern gay rights movement in the US.

A woman waves a rainbow flag outside the Stonewall Inn in New York City. Photograph: Mario Tama/Getty Images

Edie Windsor, the 84-year-old widow who brought the test case that led to the overturning of Doma, arrived at about 5pm and was cheered by the crowds in a moving scene. "To all of the gay people and their supporters who have cheered me on, thank you, thank you, thank you!" she said.

In West Hollywood, the gay district of Los Angeles, more than 1,000 attended a rally in which same-sex couples brought their children. "It means that my daughters are never going to have to explain that their family is second-class," said Jason Howe, who arrived with his married partner Adrian Perez and their twin daughters, Olivia and Clara.

In South Beach, Florida, hundreds gathered at the LGBT visitors' center to celebrate and to declare that more work was left to be done, particularly in Florida, where a 2008 constitutional amendment outlawed same-sex marriages.

Jack Tufano, 40, an architect, said he felt "relief" when the decision was announced "because my husband and I have been waiting" to get his US citizenship. The two got married last year in New York. "First thing we're going to do tomorrow is call the lawyer to get started," he said.

Others engaged in legal discussions about the supreme court decision and the Florida law, with the common refrain that "we still have a long way to go."

On a trip to Africa, President Obama did not mention the ruling directly but called on other countries to improve their treatment of minorities also. "One of the basic principles that we strongly believe in is that the judiciary is most important when it comes to minority rights, because the political process oftentimes will recognize the desires of the majority – the question is when people are on the unpopular side of an issue or a member of a minority group, where can they seek recourse – and oftentimes it's in the courts," he told a meeting of African chief justices gathered in Senegal.

Reuters in Los Angeles and South Beach contributed to this report

• This article was amended on 28 June 2013. An earlier version said the Stonewall riots took place 14 years ago. That has been corrected to 44 years.