The move comes less then three months ahead of general election which was expected in June. It was not clear whether Cerar's resignation would bring the election forward.
In pre-election opinion polls Cerar's centre-left Party of Modern Centre is trailing behind three other parties with a centre-left List of Marjan Sarec, which has never before run for parliament, being in the lead ahead of the opposition centre-right Slovenian Democratic Party.
Cerar said he would step down in the wake of a Supreme Court decision to annul the result of a September referendum that approved a 1-billion-euro railway project, the centre-left government's biggest investment programme.
"The (railway project) took a new blow from those who want to stop the positive development of Slovenia," he said. "I don't want to be part of such stories."
Earlier on Wednesday, teachers held their second one-day strike for higher wages. A number of other public sector employees are also demanding hefty pay hikes.
"Demands and suggestions have been becoming less and less feasible and even damaging to the state," Cerar said.
He told a news conference that coalition partners had been trying for a long time to undermine projects, without naming specific parties or programmes. He said he would keep the post until a new government was formed.
The government coalition, which took power in September 2014, includes Cerar's Party of Modern Centre, the Social Democrats and pensioners' party Desus.
The government had said joint public sector trade union demands amount to almost 1 billion euros ($1.24 billion), were not justified by productivity and GDP growth and would threaten planned fiscal consolidation.
Slovenia, which narrowly avoided an international bailout for its banks in 2013, returned to growth a year later. The government expects economic growth of at least 3.9 percent this year versus 5 percent in 2017, boosted by exports and investments.
It hopes to end 2018 with a budget surplus of some 0.4 percent versus a deficit of 0.8 percent last year.