It was the birthplace of the Communist party of Italy in 1921 and has a football team whose fans brandish posters of Che Guevara during matches. Ever since the founding of the republic, the western Italian port city of Livorno had been under leftwing control.

As of Sunday night, however, Livorno "la rossa" is red no longer. After almost 70 years as a bastion of the Italian left, its city council has passed into the hands of the anti-establishment Five Star Movement (M5S), whose mayoral candidate beat the centre-left's challenger in a runoff.

It was a symbolic blow for a Democratic party (PD) that had been riding high since its unprecedented victory in the European elections last month, and came as a reminder that, even with the 41% his party won in that poll, 39-year-old prime minister Matteo Renzi is far from invincible.

It was also a big – and sorely needed – triumph for Beppe Grillo's M5S, the movement that has declared itself to be neither left nor rightwing, and performed less well than expected in the European vote. Its candidate, Filippo Nogarin, an aerospace engineer and political neophyte, won 53% of the vote, ending 68 years of left-of-centre rule.

"It's not a wound; it's a real blow to the heart of the Democratic party," he told journalists. "We have taken this city and now we will give it back to the people of Livorno, who deserve better."

The port, known historically in English as Leghorn, was not the only high-profile loss for Renzi's PD, which also saw the traditionally leftwing city of Perugia fall to the centre-right and the university town of Padua go to the rightwing, anti-immigration Northern League.

But elsewhere the prime minister's party claimed victories in towns such as Bergamo and Bari, taking well over half of the 139 towns and cities voting on Sunday.

Debora Serracchiani, vice-secretary of the PD, admitted that the handful of symbolic defeats had left her party "bitter and disappointed". But she hailed the overall gains as "an extraordinary result".

The turnout in Sunday's runoffs was low by Italian standards at 49.5%, compared with 70.6% in the first round, held on the same day as the European elections. Despite that factor, some commentators saw the rise in apathy as a sign of fresh revulsion at mainstream politics following the latest corruption scandal to shake the country.

Last week the PD mayor of Venice, Giorgio Orsoni, was one of more than 30 people for whom arrest warrants were issued on suspicion of involvement in a vast bribery scheme surrounding the lagoon city's €5bn (£4bn) dam system. He is under house arrest and has denied any wrongdoing.

Details of the investigation into the alleged scheme have filled the newspapers for days, with much of it focusing on claims against local politicians from both the centre-left and centre-right.

The scandal has reminded Italians of the early 1990s, when the ruling political class was brought down by the Tangentopoli bribery scandal.

The Italian senate must vote on whether to authorise the arrest of Giancarlo Galan, the former president of the surrounding Veneto region and ex-Italian culture and agriculture minister, who, as a senator, enjoys partial immunity. The member of Silvio Berlusconi's Forza Italia party is alleged to have been paid a form of salary of €1m a year. He denies the allegations.

Italians' anger and frustration at the old political class has fuelled support for the M5S, which won 25% of the vote at last year's general election, although Renzi's image as a "scrapper" within his own party is seen to have taken some of the wind out of its sails.

But the victory of a Grillino in both Livorno and Civitavecchia, another west coast port, indicates the M5S is still capable of causing an upset. On his Facebook page, Grillo wrote that the movement – which is in talks with Ukip to form a new group in the European parliament – had proved to be an "unstoppable virus".