Rep. Kyrsten Sinema (D-AZ) has ground out a win against Rep. Martha McSally (R-AZ), a victory that marks Arizona’s slow shift towards swing-state status and that will make her the first openly bisexual senator in U.S. history and first female senator from Arizona.

The Associated Press called the race for Sinema on Monday evening, nearly a week after the election. She led led McSally by more than 38,000 votes after the latest update from Arizona’s slow-counting counties, a 49.7 percent to 48 percent lead. McSally conceded shortly after the call.

The call comes after a week of recriminations where some Republicans (though notably not McSally) accused Democrats without any evidence of trying to steal the election. Arizona’s vote-by-mail rules mean that close races almost always take days to count. While McSally led on election night, roughly one quarter of the vote had yet to be counted at that point.

The parties fought initially over uneven application by counties of the state’s signature match law, with Republicans demanding that bigger, Democratic-leaning counties stop reaching out to voters whose mail-in ballot signatures didn’t match the signature on file before eventually agreeing to let every county do so to help people have their ballots counted.

Unsurprisingly, President Trump interjected himself:

Just out — in Arizona, SIGNATURES DON’T MATCH. Electoral corruption – Call for a new Election? We must protect our Democracy! — Donald J. Trump (@realDonaldTrump) November 9, 2018

But McSally, with an eye on the future, decided against joining some other Republicans on misleading attacks on how the state was counting its votes.

The result doesn’t mean the end of McSally’s Senate hopes. Recently appointed Sen. Jon Kyl (R-AZ) is expected to resign as of January, giving Arizona Gov. Doug Ducey (R) the ability to appoint a successor, and McSally is viewed as a favorite to get this position.

The result means Democrats will have at least 47 senators next term, with the GOP holding at least 51 seats, pending results in Florida’s recount and Mississippi’s runoff that could push them to 53 seats.

The race, triggered by Sen. Jeff Flake’s (R-AZ) realization that his brand of never-Trump conservatism appealed to few voters in his state, pitted two fast-rising stars of their respective parties against one another in a state that’s gradually moved from a Republican bastion to competitive territory. Arizona’s rapidly growing Hispanic population has long given Democrats hope they could start winning there, and the suburban shift against the GOP in the Trump era helped put Sinema over the top.

Sinema, a three-term congresswoman from the Phoenix suburbs, was long viewed as the best chance for Democrats to compete statewide, and she had quietly been gearing up for a run for years.

McSally had also been touted as a star of the future since she won her Tucscon-area swing district in 2014, and she outpaced Trump by a comfortable margin in 2016.

Both displayed tenacious campaign skills and grit. But both faced serious questions about their authenticity and values as well.

McSally ran hard to the right in the primary to ward off challenges from hardline former state Sen. Kelli Ward (R) and former Maricopa County Sheriff Joe Arpaio (R), abandoning her previous support for a bill protecting DREAMers, and repeatedly embracing President Trump and his positions throughout the campaign after distancing herself from him in 2016.

Sinema, in turn, has gone from a leftist anti-war protestor and Green Party activist last decade to a moderate Blue Dog Democrat with a fiscally conservative streak during her time in Congress. She’s also dramatically changed her tone over the years.

McSally and her allies were happy to highlight this in the general election, airing ads contrasting McSally’s military service as a fighter pilot to Sinema’s anti-war protesting. And in the race’s closing weeks, they hammered Sinema for caught-on-camera moments where she dissed her home state, including one where she mocked Arizona as the “meth lab of democracy.”

Sinema’s sexual identity barely came up in the race, a sign of how far the country has come on LGBTQ rights.

McSally’s bruising attack ads helped close the race in the campaign’s closing weeks. But Sinema benefitted greatly from the lack of a primary, using the summer to air a heavy barrage of ads touting her bipartisan bona fides as McSally was having to train all of her firepower rightward.

The two also sparred over immigration, though McSally was more aggressive on the issue in a state where border security is a bipartisan issue and anti-immigrant fury has long animated the conservative base.

Both ran strong campaigns. But McSally’s late primary, a highly energized Democratic base, and Sinema’s cash edge helped put the Democrat over the top in the hard-fought race.