Iran's most conservative newspapers have strongly criticised the moderate president elected in 2013, whose foreign policy in July led to Tehran signing a landmark nuclear deal with world powers.
The accord seeks to curb Iran's atomic drive in return for lifting sanctions that have crippled its economy.
The media benefits from "a permanent security margin... so that not only can they say whatever they want, but they also sometimes act like the secret police," Rouhani told representatives of around 600 media outlets at a press event in Tehran.
"You learn from some publications who will be arrested tomorrow, what is going to be closed down tomorrow, which individual's reputation should be damaged," he said, without giving any names.
The speech came several days after the arrest of three pro-reform journalists, one of whom had recently been critical of Iran's Ayatollah Ali Khamenei, according to news agencies.
State television said the elite Revolutionary Guards had arrested "several members of an infiltration network linked to hostile Western governments who were working in the country's media and social networks."
Signup to our newsletter and follow us on Facebook and Twitter!
Rouhani told the press "some claim to be revolutionary" but "being revolutionary means not to lie... it means not to accuse others."
"Being revolutionary means giving hope to the people... reassuring people," he said.
Yet "from one part of the establishment, we attack the other part of the establishment."
"The government must be criticised, the judiciary must be criticised, the parliament must be criticised," the president said. "But criticising does not mean... smearing, insulting or lying."
Also this week, state television reported the arrest of a Lebanese-American, Nezar Zaka, on suspicion of having links to the US intelligence community.
The US State Department, while not officially confirming the arrest, said the suspect was Lebanese with permanent US residency papers.
There are also four Iranian-Americans being held in Iran, including Washington Post correspondent Jason Rezaian, who has been detained since July last year on spy charges.