"We need a prosecutor who can win the tough cases," one of Mosby's mailers stated.

In the days before the primary, Bernstein shifted strategies. Bernstein aides called Mosby unqualified for the job and filed an election law complaint against her. By then, analysts said, it was too late.

The primary election results appear "insane" when one compares Mosby's experience to Bernstein's, Brown said.

"It's like taking a new police officer off the street and making him the chief of police," he said.

But political strategist Larry Gibson, who was an adviser to Schmoke, supported Mosby. He rejected suggestions that she was unqualified, noting her experience as a prosecutor and her family's involvement in law enforcement.

Gibson said Mosby benefited from an "element of surprise" in her win over Bernstein.

"Gregg Bernstein didn't realize how strong the challenge was because most of what Marilyn Mosby did never came to his attention," Gibson said. "It was logical that he would conclude that this was not a challenger who could beat him. It was only in the last month that major portions of the campaign became visible to him."

Mosby could face defense attorney Russell A. Neverdon Sr. in the November election for the job, which pays $238,000. Neverdon needs to gather about 4,100 signatures to secure a spot on the ballot as an independent.