The Tuscan port, dubbed the "red citadel" by leading daily Il Corriere della Sera, had been a stronghold of the left for 68 years.
Filippo Nogarin, a 43-year-old engineer, created a sensation by winning 53 percent of the vote in Sunday's partial election run-off against the PD's Marco Ruggeri, 39, an employee of state-controlled oil giant Eni who had been considered the favourite.
Ruggeri had garnered 20 points more than Nogarin in the first round, but a citizens' list that had won 16 percent unexpectedly threw its weight behind Nogarin for the run-off.
The centre-left also ceded another bastion, the historic central city of Perugia, to the right.
But overall among the 27 cities at stake in Sunday's partial election, the centre-left made four gains.
The victory in Livorno for the party of ex-comedian Beppe Grillo - which also won in the port of Civitavecchia near Rome - strengthens M5S's position as Italy's second party after its performance in last month's European Union elections.
Italians backed M5S with 21.2 percent, behind the PD's 40.8 percent, in that vote.
The grassroots movement took control of the central city of Parma in the last municipal elections, in 2012.