PHOENIX – The contentious, drawn-out race for Arizona’s U.S. Senate seat flipped Thursday, with Democrat Kyrsten Sinema moving ahead of Republican Martha McSally’s lead after the latest batch of results.

Sinema took a lead of more than 9,000 votes after a blue wave of ballots were reported from the state’s two largest counties.

McSally entered the day with a lead of around 17,000 votes in the race to replace Republican Sen. Jeff Flake, who did not seek re-election.

A batch of Maricopa County votes pushed Sinema ahead by around 2,000 votes, and the lead swelled by another 7,000 after Pima County reported.

Daily updates also came from Gila, Pinal, Mohave, Yuma and Yavapai counties, which are far smaller than Maricopa and Pima.

Maricopa, Greenlee, Pima, Pinal and Yuma still had outstanding votes as of early Thursday evening, according to the Arizona Secretary of State website.

According to Garrett Archer, data analyst for the Arizona Secretary of State’s Office, 129,790 votes were counted Thursday in Maricopa County, pushing the Phoenix area past its 2010 record for most ballots cast.

Maricopa tabulated 129,790 ballots. — The AZ Data Guru (@Garrett_Archer) November 9, 2018

Maricopa county has broken it's ballots cast record set in 2010. — The AZ Data Guru (@Garrett_Archer) November 9, 2018

Sinema’s lead in the state’s largest county jumped from just over 8,000 to more than 27,000.

The Maricopa County Recorder’s Office said it still had about 345,000 ballots left to count and would report its next batch at 5 p.m. Friday.

About 195,000 of them are early, provisional and out-of-precinct ballots that voters submitted on Election Day. The rest are early ballots that were received before the election and hadn’t yet been tabulated.

“Yesterday and this morning confirmed our expectation that as the ballots are counted, Kyrsten will steadily build her advantage,” Sinema’s campaign said in a statement on Friday.

“We are confident trends will continue in Kyrsten’s direction and that she will be elected Arizona’s next U.S. senator.”

McSally’s campaign released the following statement after Thursday’s totals were announced:

“With half a million ballots left to count we remain confident that as votes continue to come in from counties across the state, Martha McSally will be elected Arizona’s next senator.”

The counting continued while a lawsuit over Tuesday’s election was playing out.

Republicans filed a lawsuit Wednesday night to challenge the way some Arizona counties count mail-in ballots.

About 75 percent of Arizona voters cast ballots by mail, but those ballots have to go through the laborious signature confirmation process, and only then can be opened and tabulated. If county recorders have issues verifying signatures they are allowed to ask voters to verify their identity.

The suit filed by four county Republican parties — Maricopa, Apache, Navajo and Yuma counties — alleges that the state’s 15 county recorders don’t follow a uniform standard for allowing voters to adjust problems with their mail-in ballots, and that two counties improperly allow those fixes after Election Day.

“You can’t give one American one set of rules for voting and another person another set of rules in the same jurisdiction,” Maricopa County Republican Party Chairman Chris Herring told KTAR News 92.3 FM’s Bruce St. James and Pamela Hughes.

In response, Maricopa County Recorder Adrian Fontes assured voters that elections officials are working to count their votes.

Lawyers for Maricopa County told a judge during a Thursday hearing that only a tiny percentage of the nearly 500,000 ballots they have yet to count could be affected by the lawsuit. A full hearing has been set for Friday afternoon.

In the meantime, a judge ruled that the counting could continue.

“I think every valid vote should count. I think every eligible United States citizen who is casting a valid ballot that is verified should have that ballot count,” Fontes said during an afternoon press conference.

“And today, an attempt to stop that process from continuing forward in Maricopa County, for the first time, where Maricopa County residents and voters and citizens now have that short cure period, they wanted to stop that from happening. And the judge told them no,” he added.

Follow @KTAR923