Iran considered pursuing a nuclear deterrent when it began its nuclear programme in the 1980s, during an eight-year war with Iraq, a former president has been quoted as saying.

Iran is implementing a deal reached with world powers in July, aimed at curbing its nuclear programme to allay Western fears it was trying to build an atomic bomb.

In an interview with Iran's Nuclear Hope magazine this week, Akbar Hashemi Rafsanjani suggested that officials were thinking about a deterrent capability when the nuclear programme first began, but insisted that it never took shape.

"When we first began, we were at war and we sought to have that possibility for the day that the enemy might use a nuclear weapon. That was the thinking. But it never became real," Rafsanjani said in the interview, which was carried by state news agency IRNA on Tuesday.

Iran fought a devastating eight-year war against Iraq in the 1980s. Iraqi dictator Saddam Hussein, the aggressor, had a nuclear programme throughout the war. He never developed a nuclear weapon but used chemical weapons later in the war.

"Our basic doctrine was always a peaceful nuclear application, but it never left our mind that if one day we should be threatened and it was imperative, we should be able to go down the other path," said Rafsanjani, who was parliament speaker during the war and became president shortly after.

He said he had travelled to Pakistan to try to meet Abdul Qadeer Khan, the father of Pakistan's nuclear weapons programme who later helped North Korea to develop a bomb, but did not secure a meeting with him.

Khan was at the centre of the world's biggest nuclear proliferation scandal in 2004 when he confessed to selling nuclear secrets to Iran, North Korea and Libya.