The mayor, a Democrat, is leaving elective office just as her national star is rising; this summer, she became the first black woman to head the United States Conference of Mayors. But her tenure in Baltimore has been rocky, especially since the unrest that followed Mr. Gray’s death after he suffered a spinal cord injury in police custody. The death set off a wave of looting, arson and violence — the worst riots the city had seen since 1968.

“There’s a feeling that she has been weakened politically by the unrest of this spring,” Kurt L. Schmoke, who was the first African-American to be elected Baltimore’s mayor, said in an interview earlier this week. But he added that in Baltimore, where the Democratic primary is tantamount to the general election and candidates can win with a plurality, “it is very difficult to beat an incumbent mayor.”

Still, several Democrats were already trying, and Friday’s announcement may prompt more to jump in. Three have formally announced their candidacy: Sheila Dixon, a popular former mayor who was forced out of office in 2010 because of a scandal; State Senator Catherine E. Pugh, who ran unsuccessfully against Ms. Rawlings-Blake in 2011; and Carl Stokes, a longtime member of the City Council.

“I was extremely surprised — caught off guard, frankly. I had no idea that she would do this,” Mr. Stokes said Friday. “I appreciate the fact that she had the wherewithal to say, ‘The city’s really on edge, we’ve got six trials coming up, we’re going to have a contentious campaign, maybe the best thing for me to do is step aside.’ ”