Long before the Supreme Court legalized same-sex marriage nationwide on Friday, hundreds of major American businesses were supporting marriage equality.
They filed legal briefs with the court. They lobbied state officials. And, perhaps most powerfully, they ramped up benefits and protections for their own LGBT employees.
Even Walmart (WMT), once known for its conservative leanings, began offering health insurance to the spouses of employees in same-sex marriages in 2014.
The momentum has been building since 2013. That's when the Supreme Court issued an important, yet narrower ruling, striking down the Defense of Marriage Act and offering federal protections to married same-sex couples.
In that case, 278 companies -- including Facebook (FB), Google (GOOGL) and Starbucks (SBUX) -- urged the court to strike down DOMA.
This time around, a similar brief was signed by 379 companies. Among them: Target (TGT), Hewlett-Packard (HPQ), General Electric (GE), Goldman Sachs (GS), Pepsico (PEP) and Wells Fargo (WFC).
Related: Marriage equality: Not so fast
Friday's decision was celebrated by many companies.
The ruling, Goldman Sachs said in a statement, "will help families across the country, make it easier for businesses to hire and keep talented people, and promote both economic growth and individual freedom."
In their brief to the court, Goldman and the other companies detailed why they wanted same-sex marriage legalized nationwide: The patchwork of laws across the country forced them to treat employees in same-sex marriages differently in some states.
That has created extra paperwork and bureaucratic tangles. Companies have done things like pay same-sex employees bigger salaries to cover tax bills not faced by straight couples.
It all has added up. In their brief with the court, the companies said it cost the private sector more than $1 billion last year.
Related: What the same-sex ruling means for couples
Companies also say that the inconsistent same-sex marriage laws made it hard for them to recruit and retain the best employees.
Workers with same-sex partners weren't usually up for relocating to a state where their marriage wasn't recognized. It also made it difficult for a company to hire new employees who may have to move to one of the 13 states that still banned same-sex marriage.
This year, 366 businesses earned a perfect score on the Human Rights Campaign's equality index gauging employee policies. That's up from 304 U.S. companies the year before.