Ms. Lightfoot’s rise was unexpected only weeks ago, when 13 other candidates were vying to run the nation’s third-largest city, many of them far better known — with decades of experience in Chicago politics and with dynastic names like Daley. Ms. Lightfoot is a lawyer who has served in appointed positions, including as head of the Chicago Police Board and as a leader of a task force that issued a scathing report on relations between the Chicago police and black residents, but she was not widely known around the city until recent months.

Ms. Lightfoot — Chicago’s 56th mayor — arrives at a pivotal moment for a Democratic city that has for the past eight years been led by Mr. Emanuel, who surprised many residents when he chose not to seek re-election.

Chicago, a city of 2.7 million residents, is wrestling with dueling realities: Tech jobs and convention business have poured into its shimmering downtown while public schools have been shuttered on the South and West Sides, and thousands of black residents have moved away. Mr. Emanuel’s administration made strides to shore up the city’s fiscal woes but residents have complained about mounting taxes and fees. Chicago’s new mayor still must come up with an additional $1 billion in the next four years to continue pulling the city out of a pension crisis.

And the city says its crime problems have been improving over the past two years, recording about half as many murders this year as it did during the same period in 2016. Still, gun and gang violence are pervasive and the city had more than 550 homicides in 2018, more than in the nation’s two larger cities, New York and Los Angeles.