Over 53 percent of voters in September voted in favor of a government railway project that was set to cost €1 billion ($1.24 billion), making it the center-left government's biggest investment program.
"I have made a decision any trustworthy politician should make in such a situation," Cerar said during a press conference late Wednesday. "You [citizens] will have a chance in the elections to judge between right and wrong and who deserves your support."
Read more: Slovenia wins maritime border dispute, Croatia defiant
He said he submitted his resignation to parliament, but that he would stay in his position until a new government could be formed.
Slovenia is due to hold a parliamentary election in June, but the date will now likely be bumped up by a few weeks.
Read more: Bled, a spa town in Slovenia
Unfair advantage in referendumThe government planned to build a 27-kilometer (16.8-mile) railway line between the Italian border city of Divaca and the state-owned Adriatic seaport Luka Koper.
But some were concerned the billion-euro price tag on the project was too high and that the government had given itself a leg-up in the campaign.
Read more: Slovenian tourism stirs 'Melania' hype
The civil society group Taxpayers Don't Give Up brought the case to Slovenia's Supreme Court, arguing the government had an unfair advantage in the referendum because it used €95,000 of public funds to support its campaign.
The court agreed with them in a ruling earlier on Wednesday.
"The government's campaign was inadmissibly one-sided," the court ruled while ordering the State Election Commission to set a new date for the referendum.
Cerar's government also faced a recent wave of strikes by public sector workers amid Slovenia's economic recovery. Many schools in the country were closed on Wednesday as teachers went on strike for the second time in a month.
rs/sms (AP, Reuters)
Each evening at 1830 UTC, DW's editors send out a selection of the day's hard news and quality feature journalism. You can sign up to receive it directly here.