Initial reports say the attacker was carrying a knife or sword. He was shot in the leg attempting to bypass a security checkpoint at the Pasteur Street complex in Tehran city centre, which is home to several government offices.
“We are trying to identify the person and his motivation," deputy governor of Tehran, Mohsen Hamedani, told Fars news agency on Monday. It is now known whether the president was inside the building at the time.
Swords and daggers are carried by Iranian men as part of traditional dress, although such items would be an unusual sight in downtown Tehran. Police have been known to confiscate weapons near official buildings.
Protests are held outside the government complex on Pasteur street on a regular basis over rising inflation and joblessness. In 2016, a miner covered himself in petrol and tried to set himself on fire in protest against his unpaid wages.
Iran has been restive in recent weeks since a new wave of protests against the government began in December over food prices. The demonstrations have morphed into calls for both President Rouhani and supreme leader Ayatollah Ali Khameni to step down.
Almost 5,000 people have been arrested in connection to the protests to date, according to Tehran prison service figures quoted last week.
Although Tehran and five world powers reached a landmark agreement to lift crippling international sanctions against the country in exchange for curbs on Iran's nuclear programme in 2015, the economic recovery has been slow and is yet to reach many Iranians' pockets.
Unemployment rose to 12.4 per cent in 2017, up 1.4 per cent on the previous year, much to citizens' frustration.
The Iranian rial hit a record low against the US dollar on Monday.
News agencies contributed to this report
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies