A former medical center chief who was kicked off Detroit's mayoral ballot and a popular county sheriff have received the most votes in a primary race and will move on to the general election, even as a state-appointed manager holds the city's thin checkbook and a bankruptcy judge considers its future path.

Write-ins received about 52 percent of the vote in Tuesday's primary, and Mike Duggan was the top write-in candidate in the race after being forced from the ballot this summer due to a residency issue.

Detroit elections employees were working into early Wednesday morning charting the various write-in names cast Tuesday and tabulating votes for each name. With write-ins from 300 of the city's 614 precincts counted, the name "Mike Duggan" was written nearly 17,000 times. The last name "Duggan" received 76 votes, while voters wrote "Mick Duggan" 63 times.

Results are unofficial and have to go before a Wayne County Board of Canvassers. Canvassers on Wednesday will begin determining which write-in candidates receive which votes from the write-in ballots.

"All of us are sharing a dream to rebuild this city together," Duggan told supporters during a victory celebration.

Wayne County Sheriff and ex-Detroit Police Chief Benny Napoleon received about 29 percent of the vote. The top two vote-getters will face off in November.

They are seeking to succeed Mayor Dave Bing, who is not seeking re-election.

City Elections Director Daniel Baxter said about 17 percent of Detroit's registered voters made it to the polls Tuesday or cast absentee ballots.

The nonpartisan primary also featured City Council, City Clerk and other races.

"This election is about you," Napoleon told his supporters Tuesday night. "It's about the people in this community who have not had a voice."

That voice likely will be muted when the new mayor takes office in January. Bankruptcy attorney Kevyn Orr will be approaching the end of his first 12 months as the city's fiscal overseer. He took the job in March under an 18-month contract.

Uncertainty and failure have been standard operating procedure for years in once-mighty Detroit. Last month, it became the largest city in the U.S. to declare bankruptcy under the weight of massive debt brought on by crushing population decline and a history of political corruption and mismanagement.

Seeking to bring stability and turn the city around, GOP Gov. Rick Snyder appointed Orr under a Michigan law that gives emergency managers nearly unlimited power.

On July 18, Orr made the Chapter 9 bankruptcy filing in federal court. He said Detroit is insolvent, unable to pay off debt that his restructuring team says could reach $20 billion. He has stopped paying on $2.5 billion in bonds, using that money to pump up struggling and underfunded city services. He also asked city creditors and Detroit's two pension funds to accept pennies on the dollar in money owed them.

"My preference would be for the governor to dissolve the emergency manager and let the mayor represent the city in bankruptcy court," Duggan told The Associated Press last week.

As its chief executive, Duggan guided the Detroit Medical Center through its own tough money times.

Of the 14 candidates and two write-ins on Tuesday's mayoral ballot, Duggan is most best qualified candidate to guide Detroit under an emergency manager and through a bankruptcy, according to 61-year-old Leilani Thornton, who voted for him.

"He would know how to work within that system to help move the bankruptcy along faster," she said. "I saw firsthand what he did at DMC. I know he has great contacts and knows how to work with people."

For Virgie Rollins, who voted for Napoleon, the next mayor must be able to deal with the bankruptcy.

"Sheriff Napoleon can work with the federal government," she said. "He knows how to work with people there."

Napoleon has said he opposes an emergency manager in Detroit.

"My pitch to him is, `You're here to straighten out the finances. You have no municipal government experience,"' Napoleon told The AP in an earlier interview. "The emergency manager puts the budget together. The mayor should be able to set the priorities."