Iran has agreed to curb some of its nuclear activities in return for about $7bn (£4.3bn) in sanctions relief, after days of intense talks in Geneva.
US President Barack Obama welcomed the deal, saying it included "substantial limitations which will help prevent Iran from building a nuclear weapon".
Iran agreed to give better access to inspectors and halt some of its work on uranium enrichment.
President Rouhani said the interim deal recognised Iran's nuclear "rights".
But he repeated, in a nationwide broadcast, that his country would never seek a nuclear weapon.
Tehran denies repeated claims by Western governments that it is seeking to develop nuclear weapons. It insists it must be allowed to enrich uranium to use in power stations.
The deal comes just months after Iran elected Mr Rouhani - regarded as a relative moderate - as its new president, in place of the hard-line Mahmoud Ahmadinejad.
It has also been backed by Iran's Supreme leader Ayatollah Ali Khamenei.
After four days of negotiations, representatives of the so-called P5+1 group of nations - the US, the UK, Russia, China, France and Germany - reached an agreement with Iran in the early hours of Sunday.
Key points of the deal have been released by the White House:
- Iran will stop enriching uranium beyond 5%, the level at which it can be used for weapons research, and reduce its stockpile of uranium enriched beyond this point
- Iran will give greater access to inspectors including daily access at Natanz and Fordo nuclear sites
- There will be no further development of the Arak plant which it is believed could produce plutonium
- In return, there will be no new nuclear-related sanctions for six months
- Iran will also receive sanctions relief worth about $7bn (£4.3bn) on sectors including precious metals
US Secretary of State John Kerry said the agreement would make the region safer for its allies, including Israel.
But the Israeli Prime Minister Benjamin Netanyahu told his cabinet it was a "historic mistake" and that his country reserved the right to defend itself.
"Today the world became a much more dangerous place because the most dangerous regime in the world made a significant step in obtaining the most dangerous weapons in the world," he said.
At a later news conference, Mr Netanyahu said Israel would not be bound by the agreement.
"We cannot and will not allow a regime that calls for the destruction of Israel to obtain the means to achieve this goal.
"Israel has many friends and allies, but when they're mistaken, its my duty to speak out."
The Israeli comments came as it was revealed that the US and Iran had held a series of face-to-face talks in recent months that paved the way for the agreement but were kept secret even from their allies.
At least five meetings, involving Deputy Secretary of State William Burns, Vice President Joe Biden's senior foreign policy adviser Jake Sullivan and Iranian officials, began in March at undisclosed locations, including the Gulf state of Oman, according to the Associated Press news agency.
The final four meetings were held after President Rouhani was elected in August. The talks were personally authorised by President Obama, AP reports quoting senior US administration officials.
The officials told AP they were "convinced that the outreach had the blessing of Ayatollah Khamenei".
Oman's Sultan Qaboos played a key role after offering himself as a mediator, according to AP.
Iran's Foreign Minister Mohammad Javad Zarif said the agreement was an opportunity for the "removal of any doubts about the exclusively peaceful nature of Iran's nuclear programme".
But he insisted that Iran had not given up its right to enrich uranium.
"We believe that the current agreement, the current plan of action as we call it, in two distinct places has a very clear reference to the fact that Iranian enrichment programme will continue and will be a part of any agreement, now and in the future," he said.
The US denied any such right had been conceded, while UK Foreign Secretary William Hague said the agreement was "good news for the whole world".
But Mr Obama warned that if Iran fail to keep its commitments, "we will turn off the relief and ratchet up the pressure".
This deal may be the most significant agreement between the world powers and Iran for a decade, says the BBC's James Reynolds in Geneva.
Negotiators had been working since Wednesday to reach an agreement that was acceptable to both sides.
As hopes of a deal grew stronger, foreign ministers of the P5+1 joined them in Geneva.
But it only became clear that a breakthrough had been made in Geneva shortly before 03:00 local time (02:00 GMT) on Sunday.