"To defend our nation and territorial integrity, we will build all the weapons we will need," Hassan Rouhani told parliament in statements broadcast on state television.
Recent Iranian missile launches have triggered US sanctions and accusations they violate the spirit of a 2015 nuclear deal between Tehran and major powers.
Signed by Iran, Germany, Britain, China, France, Russia and the United States, the landmark accord saw economic sanctions on Iran lifted in exchange for Tehran curbing its nuclear activities.
"We have built missiles, we are building some and will continue to do so because it does not violate any international regulations -- not even the UN Security Council's Resolution 2231" endorsing the deal, Rouhani said.
Under Resolution 2231, Tehran is "called upon" to refrain from carrying out launches of missiles capable of delivering nuclear weapons.
Iran says all of its missiles are designed to carry conventional warheads only.
This month, US President Donald Trump said a "total termination" of the nuclear deal remained possible, after refusing to certify the 2015 accord and leaving its fate to the US Congress.
On Thursday, Congress passed new sanctions in response to Iran's ballistic missiles programme.
Tehran views Trump's hostile rhetoric and the new US sanctions as a violation of the nuclear deal.
In parliament, Rouhani accused the United States of being responsible for "insecurity" in the Middle East.