PHOENIX (AP) — Democrat Kyrsten Sinema won Arizona's open U.S. Senate seat Monday in a race that was among the most closely watched in the nation, beating Republican Rep. Martha McSally in the battle to replace GOP Sen. Jeff Flake.

The three-term congresswoman won after a slow vote count that dragged on for nearly a week after voters went to the polls on Nov. 6. She becomes Arizona's first Democratic U.S. senator since 1994. Her win cemented Arizona as a swing state after years of Republican dominance.

Sinema portrayed herself as a moderate who works across the aisle to get things done. Sinema first came to prominence as an openly bisexual Green Party activist in Phoenix.

McSally, a former Air Force pilot who embraced President Donald Trump after opposing him during the 2016 elections, had claimed that Sinema's anti-war protests 15 years ago disqualified her and said one protest amounted to what she called "treason."

Sinema and supporters rushed to a Scottsdale resort Monday night after the latest batch of ballots showed her lead to be insurmountable.

"Arizona rejected what has been far too common in our country - name calling, petty, personal attacks and doing and saying what it takes to get elected," Sinema said as scores of backers waved her purple-and-yellow campaign sign. "But Arizona proved that there is a better way forward."

McSally posted a video message to twitter. "I just called Kyrsten Sinema and congratulated her on becoming Arizona's first female senator after a hard-fought battle," McSally said in the video, her pet golden retriever by her side. "I wish her all success as she represents Arizona in the Senate."

During her six years in Congress, Sinema built one of most centrist records in the Democratic caucus, and she voted for bills backed by Trump more than 60 percent of the time. She backed legislation increasing penalties against people in the country illegally who commit crimes.

McSally's attacks on Sinema reached back more than 15 years, when Sinema was a Green Party spokeswoman and liberal activist.

Story continues

McSally backed Trump's tax cut, border security and the Affordable Care Act repeal agenda as she survived a three-way GOP primary in August, defeating two conservative challengers who claimed her support for Trump was fake. McSally also campaigned on her military record and support for the Armed Forces.

Sinema attacked McSally's leadership of last year's failed Affordable Care Act repeal effort as a sign that she would not protect Arizona residents with preexisting medical conditions. McSally argued that she would protect patients, despite her vote on the bill that would have removed many of those protections.

The contest drew more than $90 million in spending, including more than $58 million by outside groups, according to Federal Election Commission reports. Attack ads by both sides clogged the airwaves for months.

Sinema, 42, has a law degree, worked as a social worker and was a political activist in her 20s, running as an independent Green Party candidate for the Arizona House. She then became a Democrat and served several terms in the state Legislature. Sinema started as an overt liberal but developed a reputation for compromise among her Republican peers, laying the groundwork to tack to the center.

When the 9th Congressional District was created after the 2010 Census, Sinema ran for the Phoenix-area seat as a centrist and won the 2012 election.

McSally, 52, was the first female Air Force pilot to fly in combat, flying A-10 attack jets. She also was the first woman to command a fighter squadron, again in A-10s.

McSally lost her first race in Arizona's 2nd congressional district in 2012, when she was narrowly defeated by Democratic Rep. Ron Barber, who replaced Rep. Gabby Giffords after she was wounded in a 2011 assassination attempt. But McSally came back to win the 2014 election, beating Barber by a narrow margin. She was re-elected in 2016.

There's still a chance McSally becomes a senator soon. One of her political mentors, Jon Kyl, was appointed in September to fill John McCain's seat after Arizona's senior senator died following a struggle against brain cancer.

Kyl said he'd only serve through Jan. 3, which would mean the state's Republican governor, Doug Ducey, would get to select another senator. That person would run for re-election in 2020. Ducey campaigned with McSally often last month.

Flake was an outspoken critic of Trump and announced in 2017 that he would not seek re-election, acknowledging he could not win a GOP primary in the current political climate. His support of the president's initiatives, however, was mixed. He strongly backed last year's tax cut bill but criticized Trump's positions on free trade.