SOFIA, Bulgaria (AP) — Bulgaria’s parliament on Tuesday formally approved the country’s new government proposed by the two main political rivals in a bid to end a 30-months-long political crisis, restore stability and spur economic development in the poorest EU member country.

The GERB party of ex-Premier Boyko Borissov, which won the April general election, and the runner-up, the pro-European liberal coalition “We Continue the Change – Democratic Bulgaria” have agreed to form the first-ever Bulgarian government where the post of prime minister will change hands halfway through.

Lawmakers voted 132-69 to elect Nikolay Denkov, a 60-year-old chemistry professor and former education minister, as prime minister. Denkov is a founding member of the reformist “We Continue the Change” party.

In a separate vote, legislators also approved the Cabinet, in which GERB’s Maria Gabriel, a former European Commissioner, will serve as deputy head of government and foreign minister. After nine months, Denkov and Gabriel will switch positions for the rest of the term.

Even though the two parties in this unlikely coalition are fundamentally at odds, they managed to strike a deal on the key elements in the government program.

They will seek to cobble together a constitutional majority of two-thirds of parliamentary seats to push through a comprehensive overhaul of the judiciary and to implement long-awaited anti-corruption reforms in the graft-ridden country.

The Balkan country of 6.5 million is one of the most corrupt nations in the EU. It also has the worst income inequality in the 27-member bloc.

The government’s priorities include the urgent passage of the delayed 2023 budget. It also hopes to join the EU’s visa-free Schengen area and the euro zone, and to secure the release of billions of euros in EU recovery funds, by adopting the required legislation.

The new government has pledged to keep Bulgaria, a NATO and EU member, on a firm pro-Western track; to fight Russian influence in Bulgaria’s security sector; and to guarantee support for Ukraine’s defense against Russia.