Slovenia's president has proposed a snap parliamentary election in May after the prime minister unexpectedly resigned.

The election would normally be due in June, but President Borut Pahor said after meeting outgoing Prime Minister Miro Cerar on Thursday that a vote now should be held a little earlier.

Cerar announced his resignation late Wednesday after Slovenia's top court annulled last year's referendum on a key government-backed railway project and ordered a new vote.

Slovenia's president normally should try to appoint a new prime minister first, but Pahor says an early election makes more sense. He says he will discuss possible election dates with the leaders of the main parties next week.

Slovenia's parliament is expected to formally acknowledge Cerar's resignation within a week.