Former federal prosecutor Lori Lightfoot was elected Chicago mayor on Tuesday, becoming the first black woman and first openly gay person to lead the nation’s third-largest city.

Lightfoot defeated Toni Preckwinkle, who served in the City Council for 19 years before becoming Cook County Board president.

Lightfoot promised to rid City Hall of corruption and help low-income and working-class people she said had been “left behind and ignored” by Chicago’s political ruling class. It was a message that resonated with voters weary of political scandal and insider deals, and who said the city’s leaders for too long have invested in downtown at the expense of neighborhoods.

Lightfoot, 56, has never been elected to public office. She and her wife have one daughter.

Joyce Ross, 64, a resident of the city’s predominantly black West Side who is a certified nursing assistant, cast her ballot Tuesday for Lightfoot. Ross said she believes Lightfoot will be better able to clean up the police department and curb city’s violence.

She was also bothered by Preckwinkle’s association with longtime Alderman Ed Burke, who was indicted earlier this year on charges he tried to shake down a restaurant owner who wanted to build in his ward.

Lightfoot said that as mayor, she would focus on investing in neighborhoods on the West and South Sides and bring transparency and accountability to City Hall. She added she also wants to restore people’s faith in government.

Election officials said turnout was approaching 30 percent just before polls were scheduled to close.