SAN FRANCISCO — Gavin Newsom was a fresh-faced mayor a week into his job when he walked into the House of Representatives chamber for the State of the Union address in January 2004. While he watched from the balcony, President George W. Bush declared his support for a constitutional amendment to ban same-sex unions — inspiring a political gamble that would change lives and transform Newsom’s career.

As he left the chamber, Newsom overheard a couple talking about how glad they were Bush was confronting the “homosexual agenda.” That pissed him off — “it was the way they said homosexual,” he remembered — and by the time he walked out of the Capitol, he was calling his staff to talk about how the city of San Francisco could respond.

Newsom quickly decided to throw himself into the maelstrom of America’s culture wars, violating state law by granting the first official marriage licenses to same-sex couples 14 years ago Monday. The weeks that followed changed him from an inexperienced, unknown mayor to a hero for liberals and a bogeyman for conservatives.

The marriage equality fight also established Newsom’s leadership style — his impatience for action, willingness to take risks, and “like-it-or-not” edicts — and suggests that in the governor’s mansion, he’d chart a different path from the save-for-a-rainy-day, grown-up attitude of Gov. Jerry Brown.

“I had no right to do this,” Newsom, now the lieutenant governor, acknowledged in a recent interview at City Hall. “We didn’t have the formal authority. But we tried to exercise our moral authority and challenge the laws.”

At the time, national Democratic leaders condemned him, and some LGBT leaders still believe the move was ultimately symbolic and counterproductive, helping inflame the backlash against gay rights. “He was pretending you could have marriages no matter what the law said, that you could wave a wand and have them, and that was damaging for us,” Barney Frank, the first member of Congress to voluntarily come out as gay, said in an interview last month. “It was a very irresponsible thing to do.”

But while the marriage licenses Newsom granted were nullified by a court six months after the spectacle, many of the 4,036 couples who wedded then are among his most enthusiastic evangelists as he runs for governor.

“We lived through years of politicians equivocating, and that is not what Gavin Newsom did,” said John Lewis, who married his longtime partner Stuart Gaffney the first morning possible. “He risked his entire political future for what he knew was right.”

At the time, Massachusetts had just become the first state to legalize same-sex marriage, with a court decision that wouldn’t go into effect until May. Less than a third of Californians supported marriage equality. When Newsom first suggested issuing marriage licenses, his chief of staff, Steve Kawa — who is gay and had adopted two kids with his partner — initially thought it best not to rock the boat.

But Newsom “was so adamant about it,” said Kawa, who still has a heavy Boston accent after 25 years in San Francisco. “His whole thing was, this is a no-brainer — this is the right thing to do.”

Newsom’s staff found that crafting the first official government same-sex marriage policy in U.S. history was simpler than they had anticipated. The plans were hashed out so quickly that the 36-year-old mayor didn’t even tell his wife at the time, TV anchor Kimberly Guilfoyle, before announcing the decision on Feb. 12.

The first day had an improvisational feel — Lewis and Gaffney were wedded in the drab assessor-recorder’s office, with the city’s chief tax counsel officiating. In their only photo from that morning, they’re wearing jeans and a rumpled sweater, and big, dazed smiles.

Officials rushed to wed couples, worried they were about to be shut down. But a judge refused to halt them, and the so-called “Winter of Love” lasted a month before the state Supreme Court ordered the city to stop giving out licenses.

Within days, City Hall took on a carnival atmosphere. The line of happy couples waiting to get in snaked around the block, with some camping out overnight. Even as anti-gay protesters screamed at them, local flower vendors drove up to hand out free bouquets. Inside the ornate rotunda, cheers echoed out every few minutes, as each couple was declared “spouses for life,” in lieu of “husband and wife.”

Before Newsom’s decision, “marriage actually never crossed our minds — it was not in our vocabulary,” said Shelly Bailes, who married her partner of three decades, Ellen Pontac. The two drove down from Davis when they heard the news on the radio. “You can’t imagine, unless you’ve been through 30 years of being discriminated against, how freeing it felt,” Bailes said.

Meanwhile, a handful of other mayors around the country followed Newsom’s lead, marrying same-sex couples from Oregon to New York.

While the move won Newsom huge popularity within the 47 square miles of San Francisco, he faced condemnation from national leaders of his own party. He was essentially iced out of the Democratic National Convention that year, and then-Senate candidate Barack Obama reportedly refused to be photographed with him at a fundraiser in the city.

Newsom was blamed by party leaders for anti-marriage equality constitutional amendments that passed in 11 states in 2004, and for Democrat John Kerry’s loss in the presidential race — an anti-marriage equality amendment was thought to boost conservative turnout in the deciding state of Ohio, which Kerry lost by 2 percent.

That meant Bush got to appoint two Supreme Court justices, Harvard Law School Professor Michael Klarman pointed out. On the other hand, “the fact that you actually had weddings in San Francisco was incredibly inspiring for a lot of people and activists,” he said, and sparked conversations that changed peoples’ minds on the issue. “Newsom was putting himself on the wrong side of the law, but it was the right side of history.”

Newsom’s decision “did energize a very conservative vote,” Sen. Dianne Feinstein told reporters at the time. “It gave them a position to rally around… I think that whole issue has been too much, too fast, too soon.” (A Feinstein spokesman said she was referring to the public’s perception.)

Comments like that hurt, Newsom said. “These were all my heroes, turning their backs,” he said, adding that he felt a “physical revulsion” to Democratic politicians painting themselves as gay rights supporters but refusing to back marriage equality. “It was so unconscionable that they sat here and said, ‘civil unions are good enough,’ and literally looked you in the eye and said, ‘I’m an advocate for you,’ and all these guys got away with it.”

After the marriages were nullified in August 2004, the city and several couples filed a lawsuit arguing that banning same-sex marriage was unconstitutional. That led to the California Supreme Court legalizing it in 2008, until voters approved the anti-gay marriage Proposition 8 later that year.

Newsom gave his opponents a political gift in that campaign: At a hastily called press conference after the court decision, he cavalierly declared that marriage equality would happen “whether you like it or not.” Those words were repeated in a barrage of damaging TV ads.

Proposition 8 was overturned in the federal courts, and the U.S. Supreme Court made same-sex marriage legal nationwide in 2015 — 11 years after Newsom jumped into the debate.

Marriage equality is a non-issue in California politics today. But as he runs for governor, Newsom sees parallels between the political arena in 2004 and now, as the state faces off with another conservative federal government. At the time, he said, “we pushed back with not just resistance… but with a positive alternative, that this is not about opposing (Bush), this is about celebrating these families.” Now he said he wants to take a similar approach, putting forward an alternative to the Trump administration with policies like single-payer health care.

The month of marriages shaped Newsom’s political outlook, he said, teaching him to ignore naysayers when he believes he’s on the right side of history. That’s what he did in 2016, when he pushed a sweeping gun control ballot measure, even though the legislature had already passed some of the same provisions and Democrats worried the initiative could cost them in down-ballot races.

Newsom’s opponents argue he’s less principled than he paints himself to be, pointing to flip-flops on other issues like the state’s high-speed rail project.

With the marriage license move, “he was looking for the hottest issue of the day,” said Tom Ammiano, a gay former San Francisco supervisor and Newsom adversary. While he said Newsom deserves credit for doing the right thing, “there’s many of us who feel that he’s opportunistic.”

Still, most of the leaders who forsook Newsom in 2004 have changed their tune. “Where we are today is proof positive that Gavin Newsom and California, as usual, led the charge for equality,” Feinstein said in a statement.

Asked if he would take any other civil disobedience-style actions as governor, Newsom laughed.

“I’m not interested in playing in the margins, so the answer is an open-ended one,” he said. “Let’s see what happens.”