Iran's foreign minister has apologised for recorded comments that were leaked to the public last week, creating a firestorm in Iran less than two months before presidential elections.

The recordings of Mohammad Javad Zarif included frank comments on powerful late Iranian General Qassem Soleimani, who was killed by a US drone strike in 2020. The attack at the time brought the US and Iran to the brink of war. Gen Soleimani's funeral procession in Iran drew millions of people to the streets.

In the recordings, Mr Zarif criticised Gen Soleimani's separate relations with Russia and for refusing to stop using the national carrier Iran Air for Syrian operations despite Mr Zarif's objections. Iran Air has been sanctioned by the US.

Mr Zarif said in an Instagram post on Sunday he hoped Gen Soleimani's family would forgive him. "I hope that the great people of Iran and all the lovers of General (Soleimani) and especially the great family of Soleimani, will forgive me," he said.

Mr Zarif's leaked comments were highly controversial in Iran, where officials mind their words amid a cut-throat political environment that includes the powerful Revolutionary Guard, ultimately overseen by the country's supreme leader.

Besides the criticism of Gen Soleimani, a top commander in the Guard, Mr Zarif's leaked remarks included cutting references to the limits of his power in the theocracy.

Mr Zarif could be heard saying at various points in the seven-hour tape that it was not meant for release.

"If I had known that a sentence of it would be made public, I certainly would not have mentioned it as before," he said in his Instagram post.

Mr Zarif has said he will not run for president in the upcoming election. Some had suggested him as a potential candidate to challenge hard-liners in the vote.