Iran's new moderate president, Hassan Rohani, has ruled out Tehran ever building a nuclear bomb.

Rohani reached out to the US and its allies days before making his first international appearance as Iran's president at the United Nations General Assembly in New York.

"We have never pursued or sought a nuclear bomb and we are not going to do so," Rohani told US television NBC. "We are solely seeking peaceful nuclear technology."

Elected in June to replace Mahmoud Ahmadinejad, Rohani has brought a breath of fresh air to relations between Iran and the West, say international observers.

Iran had previously claimed that its nuclear programme was for peaceful purposes but Western governments long suspected Tehran of trying to develop a nuclear weapon.

Rohani's words came after US president Barack Obama confirmed that he had initiated an exchange of letters with his Iranian counterpart over the nuclear issue.

"In his letter, the president indicated that the US is ready to resolve the nuclear issue in a way that allows Iran to demonstrate that its nuclear programme is for exclusively peaceful purposes," said White House spokesman Jay Carney.

Rohani described the exchange as "positive and constructive".

"It could be subtle and tiny steps for a very important future," he said.

In what analysts described as a further sign of goodwill, Iran freed from jail a renowned female human rights activist. Nasrin Sotoudeh, 50, was arrested in 2010 and sentenced to six years for acting against national security.

"It was only outside the prison walls that they told me I was free," Sotoudeh told the BBC.