The Middle East is on the verge of a nuclear war triggered by a US attack on Iran in the name of preventing the country from developing its own weapons, according to ageing Cuban revolutionary Fidel Castro.

"To do this on the basis of a calculation that the Iranians are going to come running out to ask the Yankees for forgiveness is absurd," Castro said. "They [the US] will encounter a terrible resistance that will spread the conflict that cannot end up any other way than turning nuclear."

The former Cuban president said Israel would throw the first bomb, but the risk that red buttons would also be pressed in Pakistan and India was latent.

Castro made the prediction on Cuban TV last night, in a dramatic return to public life after four years in near-seclusion.

"The US is activating the machinery to destroy Iran," he said. "But the Iranians have been building up a defensive force little by little for years."

Castro said attacking Iran would have a very different result from invading Iraq. "When Bush attacked Iraq, Iraq was a divided country," he said. "Iran is not divided."

The Cuban leader also emphasised that India, Pakistan and Israel are the three nuclear powers who have refused to sign the nuclear non-proliferation treaty.

"The control that Israel has over the United States is enormous."

"US foreign policy is better described as the policy of total impunity."

The leader of the 1959 Cuban Revolution who went on to become an icon of resistance to US dominance in Latin America during the Cold War, and ended up as the great survivor of the fall of communism, fell seriously ill in 2006. After emergency intestinal surgery he handed power over to his younger brother Raul, who is now 79, first temporarily and then permanently.

Castro appeared in a couple of videotaped interviews with Cuban television in 2007 and rather more frequently in photographs greeting foreign leaders visiting the island. He had not been seen in a public setting until photographs of him visiting a science centre in Havana were published in the Communist party newspaper Granma on Monday. He was shown smiling and chatting to workers, dressed in sports clothes and looking relaxed.

Still the official head of Cuba's Communist party, Castro maintains a lively presence in print, publishing regular 'Reflections' on his own nation and the world.

In recent weeks he has turned his attention to the Middle East, prompted by the Israeli raid on an aid convoy attempting to break the blockade of Gaza on 31 May. During Monday's broadcast of a special edition of a daily public affairs show called Round Table, the 82-year-old looked rather frail and his voice was somewhat weak. He shuffled papers and quoted extensively from the Arabic press, Pentagon and Noam Chomsky, among others.

Dressed casually in a tracksuit top over a checked shirt, the man once known for always wearing military fatigues, interspersed his warnings of imminent nuclear conflict with a rambling history lecture that ranged from the roots of the Korean war to the Cuban missile crisis, by way of the war in Angola.

"We have experiences of being close to it [nuclear war]," he said. "Now I believe the threat of war has greatly increased. They [the US] is playing with fire."

News that Castro would appear on TV garnered emotional responses from Havana residents. "We are so, so excited to see him. It is unbelievable," sugar ministry worker Paula Alonso told Reuters TV. "Especially for people from the same generation, we want to see our president."

Castro's reappearance comes after last week's decision by the regime to release 52 political prisoners over the next few months, following negotiations with the Vatican and Spain. They were jailed in 2003 during a crackdown on dissidence when he was still in power. The first group of freed prisoners was expected to arrive in Madrid today.