DETROIT — He was in the race. He was out. Then he was back in again. Now Mike Duggan is the front-runner for mayor of bankrupt Detroit after winning the primary election through write-in votes.

Duggan, a former county official who led a turnaround at the Detroit Medical Center before returning to politics, got 46 percent of the vote Tuesday, according to unofficial returns. He advanced to the November election against the No. 2 finisher, Sheriff Benny Napoleon.

Two courts bounced Duggan from the ballot in June, saying he hadn't been registered long enough as a voter when he submitted petition signatures to become a candidate. Duggan, embarrassed, dropped further appeals. But just a few weeks later, he jumped back into the race as a write-in, hoping he could at least finish second in the primary.

He finished first with nearly 45,000 votes.

"When I started out, I never thought it would be possible" to pull off a successful campaign, but the mood changed as the primary election neared, Duggan said Wednesday.

"Every place I have been, people have come up to me in huge numbers, asking for lawn signs and bumper stickers," he told The Associated Press. "We were expecting a big win."

Frank Aiello, a lawyer who has worked block-by-block on state House campaigns in Detroit, said Duggan's vote total was an "amazing achievement."

"The issue of name recognition, traditionally a challenge for any candidate, is doubly important for a write-in," said Aiello, who had no role in the race. A voter "has to remember your name, walk into a polling booth and then write your name in a small blank space. It's a phenomenal expectation of a voter."

Gov. Rick Snyder was impressed as well.

"It does show a level of commitment and interest from voters," he said. "Because if you think about it, that is a much more difficult act, and to show that people took the time to do that showed there obviously are a lot of citizens that really care. ... That's a good thing."

Duggan and Napoleon, both Democrats, now start campaigning for a job that won't carry much authority until Detroit's emergency manager, Kevyn Orr, leaves city hall in fall 2014. Orr wields the real power now and, with the governor's blessing, took Detroit into Chapter 9 bankruptcy in July, a process that could last a year or more.

Napoleon, the Wayne County sheriff and former Detroit police chief, said his campaign will focus on improving neighborhoods. He'll also emphasize his standing as a lifelong Detroiter, compared to Duggan who has long worked in the city but lived in Livonia, a suburb, until last year.

"I'm confident we're going to shake up, we're going to wake up, we're going to hook up with the rest of the city," Napoleon told supporters Tuesday night after getting 30 percent of the vote.

W.F. Morris, 66, said he brought his own pencil to the voting booth to write Duggan's name.

"Look how he saved the hospital. That gave me confidence," Morris said, referring to the once-struggling Detroit Medical Center. "He helped the people. He's for the people. Color's not the issue. He's trying to get Detroit back in shape."

Duggan is white. Detroit, which is more than 80 percent black, hasn't had a white mayor in more than 40 years.

"The people want change," said Daniel Moore Jr., 70, who didn't vote for Duggan. "I may go with him. I've got to give that some thought."

AP reporters David Goodman in Detroit and Tom Krisher in Traverse City, Mich., contributed to this story. Follow Ed White at