Ahmadinejad's comments came as thousands gathered in Tehran to mark the anniversary of the 1979 revolution.
His remarks are seen as a mix of defiance with conciliatory elements in a speech which made no major announcements on the nuclear programme.
"Based on the law, we have the right to have the full [nuclear] fuel cycle," he said.
"The Iranian nation is interested in continuing its nuclear activities in the framework of the [International Atomic Energy] Agency's regulations and treaties."
He added that it would be a "humiliation" for Iran to abandon its nuclear programme and that sanctions would not harm the country.
The US has accused Iran of having a secret programme to build nuclear weapons. Tehran says its programme is for power generation only.
Thousands of people flocked to Azadi (Freedom) Square to hear Ahmadinejad. Public buildings, mosques and streets were covered with flags, lights and portraits of the late founder of Iran's Islamic revolution, Ayatollah Ruhollah Khomeini, and his successor, supreme leader Ayatollah Ali Khamenei.
Ahmadinejad had hinted that Iran would celebrate its nuclear achievements on the anniversary of the revolution that brought down the US-backed Shah government and swept the Shia Muslim clergy to power.
Ahmadinejad's earlier comments prompted talk that Iran might say it had begun installing 3,000 centrifuges at its Natanz uranium enrichment plant, defying a UN sanctions resolution which gave Tehran until February 21 to suspend enrichment or face more measures.
Officials had called for a big turnout at the celebrations to show Iranian unity in the face of Western pressure.
State television played nationalist music and showed pictures of Iranians gathering in Tehran and other cities. Some waved banners saying "Nuclear technology is our right."
|"I am so proud of Iran's atomic achievements. Nuclear technology is our right"|
Ebrahim Ahmadizadeh, a government employee
Ebrahim Ahmadizadeh, 24, a government employee, wrapped in a white shroud symbolising his willingness to become a "martyr" for his country, said: "I am so proud of Iran's atomic achievements. Nuclear technology is our right."
In Munich, on the sidelines of a security conference, Ali Larijani, Iran's chief nuclear negotiator, told Reuters on that Tehran wanted a political solution to its standoff with the West. Larijani was expected to meet EU officials on Sunday.
Some Western diplomats had said that a small group of European nations were weighing a compromise proposal they plan to put to Iran in the hope that it could end the standoff.
The proposal would permit Iran to keep its uranium enrichment infrastructure of several hundred centrifuges; but it would not be allowed to feed any processed uranium hexafluoride (UF6) into the machines while negotiating with six world powers over a package of incentives to observe UN demands.
Some Western diplomats said that neither the US nor Britain would find the idea attractive because of their concerns that Iran would gain nuclear skills merely by vacuum-testing centrifuges.
After almost three decades, many Iranians, especially the young, have lost interest in the revolution. But most remain proud of their country's nuclear programme.
Meanwhile, the semi-official news agency Mehr has quoted a Revolutionary Guards commander as saying that Iran has built "suicide" drones capable of attacking US naval ships and forcing them to leave Gulf waters.
"We have built birds without passengers [drones] that can carry out suicide operations on the US navy, at any depth if necessary, to make them leave the region in disgrace," said Ali Shoushtari, deputy commander of the Guards' land forces.
Warning about a "defeat for the enemy", Shoushtari said: "Americans know that if they confront the Islamic system, they will not be secure in the region or at home."
Ayatollah Ali Khamenei, Iran's supreme leader, vowed on Thursday to hit back at US interests worldwide if it attacked the Islamic republic to thwart its nuclear programme.
In response, the White House said it had no plans to invade Iran, and downplayed the significance of reinforcing the US military presence in the Gulf region.
Iranian leaders have repeatedly said the country's armed forces are ready for any eventuality in the current standoff with the West over its nuclear activities.