"Some say since they took office the shadow of war has been faded away. This is not correct," Khamenei was quoted as saying by state media.
"It's been people's presence in the political scene that has removed the shadow of war from the country."
Khamenei and his hardline supporters have also criticised the nuclear deal - which stiffled talk by Washington of possible military action against Iran - for failing to deliver promised economic benefits.
But speaking at the opening of a refinery that Iran says will make it self-sufficient in oil products, Rouhani defended his position.
"The nuclear deal was a national achievement. We should make use of its advantages. But some have started a fight over it," Rouhani said. He cited the new refinery, in the Gulf port city of Bandar Abbas, as a result of the deal and "interaction with the world".
One of Rouhani's main challengers, Ebrahim Raisi, an influential cleric with decades of experience in the hardline judiciary, said Iran had no need of foreign help to improve the economy and could always defend itself.
"We should not warn our people of wars and crises. We have full security in the country," Raisi said in a recorded address on state television.
"This is wrong, to wait years and years for foreign investors to come ... We should resolve issues by relying on domestic capabilities," Raisi said in comments that echoed those previously made by Khamenei, Iran's highest authority.
Rouhani has said Iran needs foreign capital to modernize its oil and gas, transportation and telecommunication sectors after decades of international isolation.
However, foreign investors are still cautious about trading with or investing in Iran, fearing penalties from remaining unilateral U.S. sanctions and President Donald Trump's tough rhetoric on the Iran.
This has caused long delays in contracts that Iran seeks with international firms to develop its oil and gas fields.
(This story has not been edited by NDTV staff and is auto-generated from a syndicated feed.)
Subscribe to our YouTube channel, like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.