TEHRAN, Iran (CNN) -- Iran's President Mahmoud Ahmadinejad on Thursday called the U.S. president inexperienced, compared him unfavorably to President George W. Bush and suggested he apologize for "interfering in Iran's affairs."

Iranian President Mahmoud Ahmadinejad lashed out at President Obama on Thursday.

"Do you think that this kind of behavior is going to solve any of your problems? It will only make people think you are someone like Bush," the semiofficial Fars news agency quoted Ahmadinejad as saying.

"You are at the beginning of your way and you are gaining experience, and we do not wish the scandals of the Bush era to be repeated during your term of office," the Iranian leader said.

President Obama, who has been in office for five months, has been treading a careful line on Iran, which has seen two weeks of street demonstrations following a disputed presidential election there. Watch how U.S.-Iran relations got to this point

Pro-government security forces have cracked down on the protests, with officials saying 17 people have died. Unofficial reports suggest the number is much higher.

Official results gave Ahmadinejad a 2-to-1 victory over his nearest rival, former Prime Minister Mir Hossein Moussavi. Moussavi says the results were rigged.

Obama has said Iranians must be free to demonstrate peacefully, and his administration Wednesday withdrew invitations to Iranian diplomats around the world to attend U.S. embassy Fourth of July parties.

The extension of invitations last month was seen as a cautious outreach to Iran, which has not had diplomatic relations with Washington for 30 years.

Obama said Tuesday that Iran's government must justify itself not in the eyes of the United States, but in the opinion of its own people.

"A sizable percentage of the Iranian people themselves ... consider this election illegitimate," he said at a White House news conference.

"It is not too late for the Iranian government to recognize that there is a peaceful path that will lead to stability and prosperity," he said. "We hope they take it." Timeline of election violence »

Ahmadinejad said Thursday that even 5- and 6-year-olds would not allow insults to the Iranian nation, telling Obama: "We hope that you will avoid interfering in Iran's affairs and somehow express your regret so that the Iranian nation can become aware of your regret. If there is real change, the Iranian nation will welcome it."