Facing an election in May where he hopes to secure a second four-year term, Mr Rouhani has had to defend himself from opponents who say he has been too eager to appease the West, after agreeing to curb Iran's nuclear programme in exchange for the lifting of sanctions.
US President Donald Trump has criticised the nuclear deal and said during his election campaign he would stop Iran's missile programme. After Iran test-fired a new ballistic missile in January, Mr Trump tweeted that it was 'playing with fire'.
Addressing an event showcasing some locally built military hardware, broadcast on state TV, Mr Rouhani said, "The strengthening of the capability of the Iranian armed forces ... is only for defending the country and we will ask no one's permission to build up the armed forces, and to build missiles and aircraft."
He said Iran has never had "aggressive aims, but peace is not a one-way road and if we decide to be peaceful the other party ... may not. So there is a need for vigilance."
Iran says its missile tests are not covered by the nuclear deal.
(Reporting by Dubai newsroom, Editing by Robin Pomeroy)
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)