His comments echo the response from Russia, which like Iran is allied to Syria, and from Syria itself.
At least six people are reported to have been killed in the missile strikes in the early hours of Friday.
The strikes followed Wednesday's suspected chemical attack on the rebel-held town of Khan Sheikhoun, in which 89 people are reported to have died.
The Syrian military denied using any chemical agents, while its ally Russia said - without providing evidence - that an air strike hit a storage facility where rebels were keeping chemical weapons.
The UK's Foreign Secretary Boris Johnson called off a visit to Moscow, saying the situation had changed "fundamentally" and he would work with the US in pursuit of a ceasefire.
On Saturday in the Syrian capital Damascus and around the world, people protested against the air strikes, insisting there should be no US war against Syria.
What did Iran's president say?
In a speech broadcast on state television, Mr Rouhani said: "The man who is now in office in America claimed that he wanted to fight terrorism. But today, all the terrorists in Syria are celebrating this US attack.
"Why did you help terrorist groups and support them in your first move?"
Iran has used the term "terrorist groups" to refer to rebels, many backed by the US, who are fighting against Syria's President Bashar al-Assad.
But Mr Rouhani backed calls for an independent inquiry into the suspected chemical weapons attack.
