WASHINGTON — The Supreme Court’s decision on Wednesday to strike down the federal law against same-sex marriage brought a stunning improvement in the lives of Steven Infante, an immigrant from Colombia, and his American husband — less than an hour after the ruling was announced.

Mr. Infante and his spouse, Sean Brooks, were on their way to an immigration court in Manhattan where Mr. Infante would face what might have been his last hearing before he would be deported from the United States.

But just before they arrived, the couple’s lawyers heard the news from the Supreme Court.

“I thought it must be good news, because they were screaming like a soccer game, ‘We won 5 to 4,’ ” Mr. Infante said, referring to the justices’ tally in ruling that the law, the Defense of Marriage Act, or DOMA, was unconstitutional. Instead of ordering Mr. Infante’s expulsion, the immigration judge examined the decision and cleared the way for him to remain in this country with his husband as long as he wanted, as a legal permanent resident.

For gay Americans married to foreigners, the impact of the federal marriage act had been severe, leaving many living in fear that they could be separated from their spouses. After the Supreme Court invalidated the law, the change for many couples promises to be significant and swift.