BRATISLAVA, Slovakia — Slovakia’s prime minister, Robert Fico, will remain in office even though his center-left party lost its majority in Parliament on March 5, in an election in which far-right extremists made strong gains. Mr. Fico on Thursday cobbled together a coalition with three other parties: a center-right party, a Slovak nationalist party and a party representing the country’s Hungarian minority. The coalition will have a slim majority, 81 of the 150 seats in Parliament.

The tenure of Mr. Fico, who led the country from 2006 to 2010 and has led it again since 2012, has been marred by several corruption scandals, but he managed to cling to office by persuading two parties that had sharply criticized him to join him in governing. The alternative would have been a six-party right-wing coalition led by the center-right Freedom and Solidarity party, which came in second to Mr. Fico’s Smer-Social Democracy party, but leaders of those parties deemed that unlikely because the coalition would be unstable.

The biggest surprise in the election was the success of the extreme-right People’s Party-Our Slovakia, led by Marian Kotleba, a regional governor who has spoken favorably of Jozef Tiso, who led a Nazi-backed puppet government during World War II, helped send the country’s Jews to their deaths and was eventually hanged for treason. The party picked up 14 seats in Parliament, but none of the other parties would work with its members during the negotiations over forming a new government.