The 71-year-old former state prosecutor said the aim would be "to preserve the Filipino people and the youth of this land".
About 6,000 people have been killed in six months under Mr Duterte's anti-drugs crackdown.
He says he is acting to prevent the country from becoming a narco-state.
"If I wanted to, and it will deteriorate into something really very virulent, I will declare martial law if I wanted to. No one will be able to stop me," Mr Duterte said in a speech to businesspeople in the southern city of Davao on Saturday.
"My country transcends everything else, even the limitations," he added.
Martial rule would allow Mr Duterte to use the military to enforce civilian law and detain people at length without charge.
The Philippines constitution says a president can only declare martial law for 60 days and then only to stop an invasion or a rebellion. Parliament can revoke the measure within 48 hours while the Supreme Court can review its legality.
But Mr Duterte said the 60-day limit "would be gone".
"If I have to declare martial law, I will declare it. Not about invasion, insurrection, not about danger. I will declare martial law to preserve my nation, period," he said.
However, his comments contradict remarks made last month when he appeared to rule out the use of martial law, saying it was "nonsense" and had not improved people's lives in the past.
Martial law was last imposed in the Philippines in 1972 under dictator Ferdinand Marcos, who said it was necessary to combat crime and a communist insurgency. It was lifted in 1981,
Mr Duterte has vowed to rid the country of illegal drugs, which he says affects about four million people. His campaign has seen thousands die in police operations and unexplained killings by suspected vigilantes.
About a million drug dealers and users have handed themselves in to police.
The crackdown has led to international condemnation, with US President Barack Obama urging Mr Duterte to prosecute his war "the right way".
Some human rights lawyers say Mr Duterte's support for a shoot-to-kill policy could make him vulnerable to prosecution for crimes against humanity at the International Criminal Court (ICC).
Martial law could be imposed in the Philippines if the drugs problem worsens, President Rodrigo Duterte has said.