The Philippines has pulled off a diplomatic U-turn, reviving its traditional defence ties with Washington years after spurning it in favour of Beijing.

The pivot appears to indicate Manila believes a robust partnership with Washington can help it stop China from trampling on its rights in the South China Sea, analysts said.

But the rapprochement also risks putting Manila at odds with Beijing -- and sparking a backlash at home.

After former president Rodrigo Duterte trashed the Philippine-US alliance while seeking closer ties with China, his successor Ferdinand Marcos Jr has sought to strike a more balanced approach -- describing Manila as a "friend to all, an enemy to none".

But Marcos has also expanded defence ties with Washington, announcing this week the location of four additional military bases to be used by US troops.

While there are no indications he will seek to cut Beijing off -- he met President Xi Jinping there in January -- analysts said the shift in policy is clear.

Manila thinks that "there's basically nothing the Philippines can do to appease China", said Greg Poling, director of the US-based Asia Maritime Transparency Initiative.

"If a Philippine government wants to defend Philippine rights, the only possible recourse is deterrence and that means strengthening the alliance with the Americans," he added.

- 'Doing the right thing' -

Relations between Washington and Manila began to improve towards the end of Duterte's six-year term, as he came to understand his pivot towards Beijing had failed to put the brakes on its bid to expand its control in the South China Sea.

Beijing claims almost the entire waterway, deploying hundreds of vessels there to patrol the waters and swarm reefs.

It has also ignored a 2016 international court ruling that its claims have no legal basis.

Marcos's visit to Beijing in January, where he and Xi called for the "friendly" handling of maritime disputes, did little to prevent a row erupting weeks later when Manila accused a Chinese security vessel of using a military-grade laser light against a Philippine patrol boat.

Since the start of his presidency, Marcos has received several top US officials, including Vice President Kamala Harris.

They have pledged the United States' "unwavering" and "ironclad" commitment to defending the Philippines under the countries' decades-old mutual defence treaty.

"There is a sense of optimism that (the Philippine) government... is doing the right thing now," said Jay Batongbacal, director of the University of the Philippines' Institute for Maritime Affairs and Law of the Sea.

"Beijing may try to punish the Philippines, but the truth is the Philippines' economic relations with the US, Japan and other traditional partners still far outweigh China's."

- 'China's maritime ambitions' -

The Philippines' proximity to Taiwan, a self-governing democratic island that Beijing claims as its own, could potentially make it a key US partner in the event of a Chinese invasion.

In February, Manila and Washington struck a deal to give US forces access to more Philippine military bases under the Enhanced Defense Cooperation Agreement, or EDCA.

The EDCA was signed in 2014 under Duterte's predecessor, Benigno Aquino, and allowed US forces to rotate through five bases and use them to store defence equipment and supplies.

But it stalled under Duterte, who threatened to cancel the accord.

Marcos has sought to accelerate its implementation and, to China's chagrin, agreed to give US forces a bigger footprint in the country, particularly in the north.

The news of the expanded base access prompted China to accuse the United States of "endangering regional peace and stability".

"I think the message we want to convey is Luzon Strait and the northern provinces are ours," said Rommel Jude Ong, a former vice commander of the Philippine Navy.

"And we have the right to take measures to defend these strategic areas and insulate them from China's maritime ambitions."

- 'On the front line' -

The United States has a complex history with its former colony the Philippines, and its military presence in the archipelago remains a sensitive issue.

It previously had two major military bases on the main island of Luzon, but they were closed in the early 1990s after years of protests, and not everyone supports giving US troops access to Philippine bases.

"The US is dragging us into its war with China," said activist Liza Maza, 65, who campaigned against the US bases more than 30 years ago and feels like she has been "transported back in time" with the EDCA.

Manuel Mamba, governor of Cagayan, just south of Taiwan, has opposed hosting EDCA sites in his province for fear of jeopardising Chinese investment and becoming a target.

For his part, Marcos appears to have accepted the inevitability of his country's involvement in the event of a war in Taiwan.

"It's very hard to imagine a scenario where the Philippines will not somehow get involved," he told Japanese news outlet Nikkei Asia in February.

"We feel that we're very much on the front line."