"The violations in the election are very serious and you are right to be deeply hurt," he said in a statement on his website.
"But I firmly call on you not to subject any individual or groups to hurt."
The official results gave Mr Ahmadinejad 63% of the vote against 34% for Mr Mousavi.
Iran's Supreme Leader Ayatollah Ali Khamenei praised the high turnout of 85%, described the count as a "real celebration" and called for calm.
"Enemies may want to spoil the sweetness of this event... with some kind of ill-intentioned provocations," the ayatollah said.
Mr Mousavi's supporters said the election had been stolen and vowed to seek a re-run.
But observers say this will have little chance of success.
Some of the protesters in Tehran wore Mr Mousavi's campaign colour of green and chanted "Down with the dictator", news agencies report.
Four police motorbikes were set on fire near the interior ministry, where votes had been counted, the BBC's John Simpson in Tehran says.
Interior Minister Sadeq Mahsouli warned that any demonstrations needed official permission, and none had been given.
One opposition newspaper has been closed down and BBC websites also appear to have been blocked by the Iranian authorities. The AP news agency reports that mobile phone services have been blocked in Tehran.
Mr Mousavi had said there was a shortage of ballot papers and alleged that millions of people had been denied the right to vote.
His election monitors were not allowed enough access to polling stations, he added.
The BBC's Jon Leyne in Tehran says the result has been greeted with surprise and with deep scepticism by many Iranians.
The figures, if they are to be believed, show
winning strongly even in the heartland of Mr Mousavi.
The scale of Mr Ahmadinejad's win means that many people who voted for a reformist candidate in the previous presidential election four years ago have apparently switched their votes to Mr Ahmadinejad, he adds.
However, the president does enjoy the support of many of the urban poor and rural dwellers.
"I am happy that my candidate has won - he helps the poor and he catches the thieves," sandwich seller Kamra Mohammadi, 22, told AFP.
Mr Mousavi gains much of his support from the middle classes and the educated urban population.
Surge of interest
BBC Iranian affairs analyst Sadeq Saba says the result means that hope for peaceful reform in Iran may die for a long time.
Mahmoud Ahmadinejad's supporters have been celebrating the result
There had been a surge of interest in
Iran's presidential election,
with unprecedented live television debates between the candidates and rallies attended by thousands.
There were long queues at polling stations on Friday, with turnout reaching 85%.
Four candidates contested the election, with Mohsen Razai and Mehdi Karroubi only registering about 1% of the vote each.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.