PITTSBURGH — More than five decades after Cleveland became the first, followed by Cincinnati, Detroit and virtually every other major city in the Midwest and Northeast, Pittsburgh is finally poised to join their ranks and make history this fall by electing a Black mayor.

The all-but-certain victory of state Rep. Ed Gainey (D) comes as the once-battered former steel town, these days dubbed one of America’s most livable cities, looks hard at the racial inequities that have meant vastly different experiences and opportunities for its African American residents. Gainey’s campaign this spring reflected such soul-searching, especially in the wake of nationwide protests over police force in communities of color.

“I believe this city right now is thinking differently,” the 51-year-old native says. “For so long, there has been isolation. There has been institutional racism that has dominated the area in many ways, and I think what you are seeing is a new city emerging.”

Gainey is the first candidate to defeat a sitting mayor here in nearly 90 years. He received 46.1 percent of the vote in the May 18 Democratic primary to Bill Peduto’s 39.5 percent; given that only one political party has power locally, primaries serve as the de facto election.

During the campaign, the incumbent also had talked about the separation of “White Pittsburgh and Black Pittsburgh” and how he had “worked hard to change that, but we’re not there yet.”

The challenger, however, highlighted priorities that responded specifically to Black Lives Matter demonstrations and the 2020 murder of George Floyd under the knee of a Minneapolis police officer. He would ban no-knock warrants, he pledged, strengthen the Citizen Police Review Board and redirect police funding for military-style gear to other public safety needs.

The ideas won out. “Gainey putting forth a plan to redirect funding away from military equipment for the police to better training is a small step in the right direction,” said Matt Frankwitt, a hospital administrative assistant and former Peduto voter. And Gainey’s proposal to deploy trained professionals on 911 calls involving mental health issues “is an even bigger step in the right direction.”

Despite all the outside accolades in recent years over Pittsburgh’s livability — part of a renaissance driven by tech jobs, health care and an increasingly vibrant art scene — the story line has been much different for the 23 percent of residents who are Black.

Their neighborhoods often are burdened by too many abandoned buildings and too few grocery stores. Some are being overtaken by gentrification and residents pushed out. The neighborhood of East Liberty, four miles from downtown, now features luxury apartments and stores like Bonobos and Warby Parker. A retail business development, anchored by a Whole Foods, stands where 200 people lived in an affordable-housing complex until 2017.

A 2019 city-commissioned report on gender and racial equity quantified the problems: For Black women in Pittsburgh, 18 out of every 1,000 pregnancies end in a fetal death, compared with 9 out of 1,000 for White women. Black women in Pittsburgh are five times as likely to live in poverty as White men.

“Black women and men in other cities have better health, income, employment, and educational outcomes than Pittsburgh’s Black residents,” the report stated.

Gabriel Winant, a University of Chicago historian of social structures and inequality, said these racial inequities are rooted in history. During the 1940s, as a second surge of the Great Migration drew more African Americans from the South, fewer Black families settled here than in other Midwestern and Northern cities. Their numbers remain proportionally smaller today.

Pittsburgh’s labor history is another factor. Unions helped ensure that the best positions in the steel mills went to White men, with Black men holding the least lucrative and most dangerous jobs. “Racial hierarchy gets reinforced through economic structure,” Winant noted.

As a boy, Gainey lived with his mother in a federally subsidized high-rise called Liberty Park. It seemed disconnected from civic life.

“Growing up, I never met a politician,” he said. “They didn’t knock on my door. They didn’t come to my school. We didn’t get calls asking what candidate we would like to support. That didn’t happen in my area. We didn’t have community meetings.”

The building slid into disrepair, and he saw drug deals in the lobby and fights in the halls. Yet he remembers positives, too, including basketball games on nearby city courts and sledding on snow-covered hills. The adults in the neighborhood “poured love onto us,” he recalled.

His first exposure to politics came in 1990, when he was a freshman at Morgan State University in Baltimore. The campus was in turmoil, with students occupying administrative buildings and demanding more state funding for Maryland’s historically Black colleges and universities. On his very first day, a professor asked him why he was in class instead of protesting. “It was liberating at the time,” he said, “and it was informative. I had never been in that environment, everyone working towards one goal.”

Gainey majored in business management, but when he returned to Pittsburgh, politics drove his ambition. He took a job as a legislative aide to a state representative and, after switching to a city economic-development position, ran against that same representative.

He lost in 2004 and 2006, kept working in the administrations of two successive Pittsburgh mayors, then ran a third time in 2012. That campaign ended in victory, and he has served in the legislature ever since, focusing on affordable housing and gun control and pushing to legalize cannabis. His district includes a swath of majority-Black neighborhoods in Pittsburgh as well as in the eastern suburbs in Allegheny County. (Homewood is among those city neighborhoods. It is where the legislator’s younger sister was shot dead in 2016.)

Jasiri X, a local hip-hop artist and activist, said Gainey “loves being around people” and has a knack for creating rapport with others. He noticed this at Black Lives Matter demonstrations. “We were walking through East Liberty,” he said, “and [Gainey] knew everybody, said hi to everybody. That’s his personality.”

Last year’s rallies were volatile in Pittsburgh, with armored police dispersing some crowds with tear gas. When officers arrested one protest leader last August by pulling him into an unmarked van, others regrouped outside the mayor’s home. For several nights, they clogged his street and demanded his resignation before being forced to leave.

Peduto, who declined an interview request for this article, seemed to take it personally. He responded months later to a conservative detractor on Twitter. “You do realize the Protestors from last year also oppose me?” he wrote. “Interesting to know. Radical right and Radical left joining together. This happened 90 years ago. It ended up terribly.” The tweet elicited hundreds of replies, some aghast at the mayor’s apparent reference to Nazi Germany.

For some voters, the local and national dialogue on race changed their priorities. Artist Kirsten Ervin canvassed for Peduto in 2013 and supported him again four years later. She credits the mayor — a policy wonk whose enthusiasm for urban planning earned him the nickname “Bike Lane Bill” — with streamlining bureaucracy and cutting red tape during his two terms. But in May she voted for Gainey.

As “a middle-class White woman” — one who lives in the trendy neighborhood of Lawrenceville — “my life won’t change depending on who is mayor,” she said. “But I feel like we need leadership that gets these things a little better.”

She also remembers Gainey’s check-ins at the Greater Pittsburgh Food Bank, where she volunteered during the pandemic. “He was there. He seemed to know everyone,” she said.

“Peduto is like the principal who goes into his office and makes a plan for the semester,” Ervin said, “and Gainey is like the principal who knows every kid’s name.”

Gainey plans to spend the four-plus months before the November general election continuing his work in the state Capitol and preparing for his expected administration. He has discussed some concrete goals, such as elevating Black women to prominent positions in city government and requiring businesses that seek a public subsidy to contribute to a centralized job-training fund, but acknowledges that racial inequities will take decades to resolve.

His “greatest hope” is that Pittsburgh starts to truly become “a city for all.”

“If we can build that and pass it on to somebody else and continue to build on that,” Gainey said, “then we are changing the dynamics and the course we’re faced with.”