AUGUSTA, Maine — Democratic Attorney General Janet Mills is the gubernatorial Democratic primary winner under Maine's new ranked-choice voting method, the nation's biggest test of the system, officials announced Wednesday.

Mills had the most first-place votes, and her lead held after additional rounds of tabulations under the system that had voters rank candidates from first to last on the ballot. The winning result was announced eight days after Maine's primary. Democratic state Rep. Jared Golden, the Assistant House Leader, also won the right to face Republican U.S. Rep. Bruce Poliquin for Maine's 2nd Congressional District.

Additional tabulations were triggered in both races because no one collected a majority of first-round votes. Because of that, additional voting rounds eliminated last-place finishers. Those voters' second-place selections were reallocated to the remaining field.

Ranked-choice voting became a game of mathematical survival once all of the ballots were shipped to Augusta for processing at a secure location. Ballots and memory sticks from hundreds of towns had to be delivered and scanned into several computers over several days.

In the end, Mills won. When asked about what it would mean to be Maine's first female governor, she said she will run on her "merits and qualifications and ability to get stuff done."

She said she won't fight those who have called her a political insider. "I believe I'm the most qualified person for the job," she said.

Several dozen onlookers and reporters crowded a small room in Augusta as Democratic Secretary of State Matt Dunlap watched a laptop computing election results, round by round.

"I think people can trust the result," Dunlap said. "Off we go."

Proponents say the voting system eliminates spoiler candidates, moderates harsh rhetoric and ensures a consensus winner. Critics say it's complicated, unfair and potentially unconstitutional.

The system, first approved by Maine voters in 2016, was used for the first time in modern history in a statewide gubernatorial primary race featuring seven Democratic candidates.

Ranked-choice elections, also known as instant runoff elections, are currently used in 11 local jurisdictions. Maine voters on June 12 gave the green light for the system to be used for the first time in U.S. House and Senate elections in November.

Larry Sabato, director of the University of Virginia Center for Politics, said he's open to the idea and wants to see how it works plays out in Maine.

"States are the laboratories of democracy, and here's a great experiment for one laboratory. If it works well, others may adopt it. If not, then they won't," he said.

Residents were left with a cliffhanger after the first-round results. Mills led with 33 percent, followed by Adam Cote with 28 percent, Betsy Sweet with 16 percent and Mark Eves with 14 percent.

Mills will run for the seat being vacated by term-limited Republican Gov. Paul LePage.

Businessman Shawn Moody won his Republican primary with an outright majority, so there were no additional tabulations in that race.

Mills will face Moody on a crowded November gubernatorial ballot that includes several independents including entrepreneur Alan Caron, former GOP legislative candidate Ken Capron, state treasurer Terry Hayes, and former state lawmaker and mayor John Jenkins.

In the Congressional race, Golden didn't win an outright majority in the first round of voting, but he became the winner by defeating conservationist Lucas St. Clair after additional tabulations under ranked-choice voting.

Republican Rep. Bruce Poliquin is seeking a third term. He has a formidable fundraising advantage with $2.8 million in his campaign coffers.