BEIJING - Philippine President Rodrigo Duterte said it was "time to say goodbye " to the US during a visit to China on Wednesday, as the combative leader reconfigures his country's diplomatic alliances.

Duterte is in China for a four-day trip that is expected to confirm his tilt away from Washington and towards Beijing's sphere of influence.

During a speech addressing the Filipino community in Beijing, the firebrand president said the Philippines had gained little from its long alliance with the US , its former colonial ruler. "Your stay in my country was for your own benefit. So time to say goodbye , my friend," he said, as if addressing the US .

"I will not go to America anymore. I will just be insulted there," he added, before once again referring to US President Barack Obama as a "son of a whore".

Duterte , who took office in late June, said he was fed up with the Philippines ' foreign policy being dictated by a Western agenda. "What kept us from China was not our own making. I will charter a new course," he said.

Foreign policy under Duterte has dramatically shifted from that pursued under predecessor Benigno Aquino, who took Beijing to an international tribunal over its extensive territorial claims in the South China Sea and won a resounding victory.

The move infuriated Beijing. But Duterte , who took office in June shortly before the tribunal ruling, has made a point of not flaunting the outcome.

He has also suspended joint US-Philippine patrols in the South China Sea, and has threatened an end to joint military exercises.The South China Sea is of intense interest to Washington and it has repeatedly spoken out on the various territorial disputes between China and its neighbours over the strategically vital waters.

Tensions have risen between the US and China over Washington's so-called "pivot" to the Asia-Pacific, a move that Beijing says is intended to contain it.

Duterte will meet top leaders including President Xi Jinping and Premier Li Keqiang during his stay.

Hours before he spoke, Chinese foreign ministry spokeswoman Hua Chunying told a regular briefing that Beijing was pleased to move towards resolving the territorial dispute "through consultation and dialogue".

"Anyone who truly wishes for peace, stability, development and prosperity in the Asia Pacific" should welcome Duterte 's visit, she said.

In an editorial Wednesday, China's nationalist Global Times newspaper said Washington had treated Manila "as a pawn", adding Duterte was now "redesigning Philippine foreign policy based on Philippine interests".

Duterte has said his China trip will focus on promoting economic ties .

The Philippines is hoping, among other things, that Beijing will repeal a ban on imports of its bananas - an economic sanction intended to punish Manila for its South China Sea stance.

Hua said Wednesday announcements on infrastructure cooperation and economic development projects could be expected during the Philippine leader's visit.

As Duterte has cosied up to Beijing, he has repeatedly denounced the United States for criticising the deadly war on crime he instigated upon taking office.

Last month Duterte sparked a diplomatic storm when he branded Obama a "son of a whore" after being told the US president would raise the rights concerns at an Asia meeting.

Beijing, meanwhile, has enthusiastically endorsed Duterte 's war on drugs, which has seen more than 3,700 people killed and led the International Criminal Court to warn that those responsible could face charges.

Hua said Wednesday that the two sides were already in close communication about cooperating on drug control and anti-crime issues.

China has also offered to train some Filipino cadets in "anti-illegal drug and VIP security protection", according to Ramon Purugganan, deputy director of intelligence with the Philippine National Police.