The Sandinista government of Nicaragua considered themselves revolutionary Marxists, allied with Cuba and the Soviet Union in the 1980s, and were consideredcalled Communists by the Reagan administration, which funded an insurgency against them. Their domestic policies were left-wing, but not very similar to the Soviet Union’s.
They lost an election in 1990, had a peaceful transition of power, and the party continued to run in and win elections afterwards.