Portugal's prime minister has found a way to maintain government stability with the junior partner in the ruling coalition.

But the full details still need to be agreed to end a political crisis that has threatened Lisbon's adjustment under a bailout.

Prime Minister Pedro Passos Coelho said a formula had been found after meeting with the leader of the rightist CDS-PP party three times in the past 24 hours to heal the most damaging political rift since the country received a bailout in 2011.

"A formula was found to maintain government stability," Passos Coelho told journalists last night after a crisis meeting with the president to discuss the political situation.

The resignations this week of finance minister Vitor Gaspar and foreign minister Paulo Portas, who also heads the CDS-PP, have threatened to deprive the government of a majority in parliament as the country goes through its deepest slump since the 1970s.

Passos Coelho said the solution would involve a "way to guarantee the political support of the CDS-PP of the government," adding that the resignation of Portas had been a personal decision.

Still, the prime minister gave no details of the agreement and the final outcome still depends on further negotiations with Portas in coming days. It is likely to include more ministerial positions for the CDS-PP, analysts said.

Any final agreement will also have to be approved by President Anibal Cavaco Silva, who will meet with all political parties from Monday.

Portuguese assets were highly volatile during the day earlier yesterday, but by the afternoon bond yields fell and stocks recovered most of their sharp losses from a day earlier as agreement appeared closer.

But, analysts say the crisis, whatever the outcome, is likely to deepen Portugal's economic challenges. Unemployment is at record highs near 18% and the country entered its third year of recession in 2013.

Gaspar, architect of the spending cuts and tax hikes required by Portugal's lenders in exchange for a bailout, quit as finance minister on Monday, citing an erosion in support. Portas resigned the next day because he objected to the appointment of Treasury Secretary Maria Luis Albuquerque to replace Gaspar.

The threat of a prolonged crisis that could lead to elections in a few months has opened the possibility of delays to reforms and cost-cutting under the country's €78 billion bailout.

The head of the Portuguese Industry Confederation piled pressure on the government to find a solution quickly. "The crisis has to be overcome in parliament, and we think the conditions for that to happen exist," Antonio Saraiva said.

In a sign of how widespread disenchantment with austerity has become in Portugal, Saraiva also said the country has to be given more time by creditors - the European Union and International Monetary Fund - to meet budget goals under their bailout programme.

The returns investors demand to hold Portugal's 10-year bonds were about 16 basis points lower on the day at 7.34% yesterday evening. On Wednesday they surged to more than 8% - their highest since November.

Lisbon's stock market closed 3.7% higher yesterday after sliding 5.3% the previous day, as hopes grew that the government will stay on and avert an early election.

The EU and IMF are due to start their next review of the economy on July 15, but that visit might now be delayed.