Rodrigo Duterte, the president of the Philippines, has given formal notice to the US of his decision to scrap a bilateral agreement covering visiting American troops, following through on repeated threats to downgrade the defence alliance.

The visiting forces agreement (VFA), signed in 1998, accords legal status to thousands of American troops rotated in the country for humanitarian assistance and military exercises, dozens of which take place annually.

Duterte, who has made no secret of his grudge with the US and his disdain for his country’s close military relationship, believed it was time to be more militarily independent, his spokesman said.

“It’s about time we rely on ourselves. We will strengthen our own defences and not rely on any other country,” Salvador Panelo told a regular briefing, quoting Duterte.

Defence ties between the Philippines and its former colonial ruler go back to the early 1950s and are governed by a mutual defence treaty (MTD), which remains intact, along with an enhanced defence cooperation agreement made under the Obama administration.

Duterte made the decision after the top commander of his war on drugs, the former police chief Ronald dela Rosa, said his US visa had been rescinded over an issue related to the detention of a senator and critic of Duterte.

It is the first time Duterte has scrapped an agreement with the US, having throughout his more than three years in office denounced Washington for hypocrisy and for treating the Philippines “like a dog on a leash”.

Despite reassurances from his generals, Duterte has long accused US forces of conducting clandestine activities. In a speech on Monday he said US nuclear weapons were being stored in his country.

He has argued that the presence of US forces makes the Philippines a potential target for aggression.

Duterte’s move follows a Senate hearing last week during which his defence and foreign ministers spoke in favour of the VFA, both noting its overall benefits.

He said even the US president wanted him to change his mind. “Trump, and others are trying to save the [VFA]. I said I don’t want,” he said.

His foreign secretary, Teodoro Locsin, confirmed on Twitter that the US embassy in Manila had received notice. The termination will take effect after 180 days.

Duterte favours warmer ties with China and Russia than the US and has praised those countries and increased their military contributions and donations, which are dwarfed by the $1.3bn (£1bn) spent provided by the US since 1998.