PRAGUE (Reuters) - Czech President Milos Zeman appointed Ivan Pilny as finance minister on Wednesday, ending a political spat that nearly brought down the government just months before an election.

Czech Republic's President Milos Zeman speaks during the Belt and Road Forum for International Cooperation in Beijing, China May 14, 2017. REUTERS/Lintao Zhang/Pool

The former Microsoft executive replaces Andrej Babis, a billionaire businessman whose dismissal Prime Minister Bohuslav Sobotka had sought, sparking a battle between the two main parties in the center-left government.

Pilny, 72, has the task of completing the 2018 central state budget draft, aiming to cut the deficit to 50 billion crowns ($2.12 billion) from this year’s 60 billion crown target.

Pilny has said he would not seek any major changes at the ministry and that the planned deficit was sensible. He has said he would be happy with more emphasis on investments in spending.

Babis, founder of the ANO party, leaves after pressure from Sobotka, a Social Democrat, amid allegations he dodged taxes by buying tax-exempt bonds from his company Agrofert, which gave him untaxed interest income from the firm.

Babis, who has devoted much attention at the Finance Ministry to fighting tax evasion, has denied any wrongdoing.

Babis also came under pressure due to anonymously released audio tapes apparently showing him discussing with a journalist when to publish scandals of political opponents in a national newspaper which is part of Agrofert.

Babis denied interfering in news content and said the tapes were manipulated. He transferred ownership of Agrofert to a trust fund this year to comply with conflict-of-interest legislation.

Babis had initially refused to resign, but after weeks of cabinet infighting he backed down and proposed ANO party member Pilny as his replacement.

He has called the cabinet crisis, which started at the beginning of May, a political play.

The Social Democrats trail ANO by a double-digit margin in polls going into an October election.