The International Monetary Fund (IMF) will support a new economic programme for Pakistan if the government seeks one, while encouraging the resolution of disputes linked to last month's election, it said on Friday.

Cash-strapped Pakistan has grappled with the Feb. 8 election that delayed the formation of a coalition government until new Prime Minister Shehbaz Sharif was sworn in on Monday. But the IMF news boosted investor confidence and helped add to a remarkable rally in the country's bonds.

"We look forward to engaging with the new government to complete the second review under the current stand-by arrangement and, should the government request, support the formulation of a new medium-term economic programme," an IMF spokesperson said in an e-mail.

Sharif asked his government to open talks with the IMF for a new programme after clearing the stand-by arrangement, but the party of jailed former prime minister Imran Khan asked the IMF last month to ensure an audit of the disputed election before any more bailout talks.

Pakistan secured a $3 billion IMF stand-by arrangement last summer, but that runs out in April and the country is still struggling with record inflation, currency devaluation and shrinking foreign reserves.

Sharif has yet to name his finance minister, but positive news from the IMF added to investor optimism that has helped boost bonds from pricing in a high chance of a default last year to close to face value on shorter-dated maturities.

"The worst-case scenario of a contested election and a prolonged political crisis has been avoided," said Kevin Daly, head of emerging market debt at abrdn, citing the IMF but also China's decision to roll over some of Pakistan's loans.

"All in all this reduces default risk over the next 2-3 years, although one has to bear in mind that Pakistan has a record of falling off the tracks with the IMF, so that's a risk on the horizon."

Pakistan's bonds gained around 4 cents on Friday. The 2036 maturity gained the most by 1510 GMT, adding 3.85 cents to trade at 77.4 cents on the dollar.

"It's been an incredible rally," said Mark Evans, a fixed income analyst with Ninety One. He said moves on currency and interest rates helped improve Pakistan's financial position, and that they remained overweight.

"There's too much at stake for a country like Pakistan to default from a geopolitical perspective," he said.

But Pakistan's still-fragile politics, along with daunting economic troubles, leave risks.

The IMF encouraged a peaceful resolution of all electoral disputes, given the importance of the institutional environment for economic stability and growth.

Pakistan's finance ministry did not immediately respond to a request for a comment.

Emre Akcakmak, head of frontier markets with East Capital, said investors would watch progress closely.

"There are reasons to be more optimistic compared to the darkest days of last year, but the country is still in the beginning of a much-awaited economic rebalancing and reform process," Akcakmak said.

(Reporting by Ariba Shahid in Karachi; Additional reporting by Libby George in London; Writing by Shivam Patel; Editing by YP Rajesh, Clarence Fernandez, Alexander Smith and Nick Macfie)