Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Last year, the mayor of a seen-better-days steel town in Western Pennsylvania became the poster child of President Donald Trump's appeal to white working-class Democrats. But he’ll soon be out of work after a 26-year-old assistant band director at the local high school beat him in a Democratic primary.

Monessen Mayor Louis Mavrakis’ outspoken praise for Trump and his invitation for the candidate to speak in the town turned the mayor into a media sensation. The 79-year-old former union organizer helped decode Trump’s appeal in the Rust Belt on Sunday political talk shows and for major newspapers, where he was quoted saying things like: “If ISIS was to come to Monessen, they’d keep on going. They’d say someone already bombed the goddamn place."

Trump himself made a high-profile visit to Monessen, a town of just 7,500, on Mavrakis’ invitation. Trump stood in front of a wall of recycled trash to slam free-trade policies and promised to bring back good-paying coal mining and steel-making jobs.

In this undated image, Lou Mavrakis is shown. Mavrakis recently lost his incumbent bid for the mayoral race of Monessen, PA. Courtesy Observer-Reporter

But Mavrakis’ coup in getting Trump to town also helped lead to his downfall.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

When a group of residents protested his visit, they were led by Matt Shorraw, a local community activist whose family has been in the town for generations.

“What bothered me the most was Trump’s visit got our mayor a lot of press, but he basically used that press to say our city is a dump,” Shorraw told NBC News.

Shorraw resolved to run for mayor, even though he had never held public office and was only in his mid-20s.

On Tuesday, he narrowly defeated Mavrakis in the Democratic primary. And with no Republican on the ballot in November, Shorraw is all but guaranteed to be the youngest mayor in the town’s history.

In this undated image, Matthew Shorraw is shown. Shorraw recently won the mayoral race for town of Monessen, PA. Courtesy Observer-Reporter

"I think a bit of the Trump phenomenon was that people wanted something completely different. And I think that might have been the case in Monessen, too, with me," said Shorraw.

Biff Rendar, a local Democratic activist who supported Shorraw, said “you cannot find two more opposite people" than Shorraw and Mavrakis.

In photos and videos posted on his campaign’s website, Shorraw looks more like the stereotype of a Brooklyn hipster than a Rust Belt worker. His announcement video features him wearing a plaid shirt and blazer with thick-rimmed plastic glasses.

But he got noticed for the community projects he has taken on since he was 18, such as revitalizing an amphitheater. It demonstrated an optimism for the town that voters found refreshing, said Rendar.

The Westmoreland Democratic Party broke its longstanding precedent of not endorsing in primaries in order to back Shorraw after Mavrakis brought Trump to town.

“Mavrakis was already lost to us," said Lorraine Petrosky, the party chairwoman.

CLARIFICATION (4:45 p.m., May 26, 2017): While Mayor Mavrakis repeatedly praised Trump during the presidential campaign, the mayor called after the publication of this article to say that he did not vote for Trump.