MANILA -- Malaysian Prime Minister Mahathir Mohamad on Thursday warned Philippines about becoming too indebted to China as Manila draws down Chinese funds to build much-needed infrastructure.

Earlier this week, the Philippine Senate conducted an inquiry into the interest rates and questionable terms offered by China that had been lapped up by the administration of President Rodrigo Duterte, who is keen to improve infrastructure in the country. China had opened a $9 billion credit line to Philippines during Duterte's state visit to Beijing in 2016. Of that amount, at least $300 million has been agreed in loans to develop dams and irrigation projects so far.

"If you borrow huge sums of money from China and you cannot pay, you know when a person is a borrower he is under the control of the lender, so we have to be very careful with that," Mahathir told ABS-CBN News Channel before his bilateral meeting with Duterte.

Mahathir, who was in the Philippine capital for a two-day official visit, shelved two China-funded projects, including a $20 billion railway, last year soon after he was voted into power, citing unfavorable terms to Malaysia. His move was a major blow to Beijing's Belt and Road infrastructure program, which is under tighter scrutiny in countries where it sponsors projects.

Asked about regional concerns over China's "debt trap," Mahathir said: "This is something that China has been accused of but it is also the country's [referring to the borrower] concern, which can regulate or limit this influence from China."

In the same interview, the 93-year old leader also spoke about the dangers of an influx of foreigners, saying that it "might disturb the political equations in the country."

Over 300,000 Chinese have been granted work permits in Philippine since 2016, when Duterte won the presidency and embraced China as a key economic partner despite a territorial dispute in the South China Sea

Mahathir said if "huge numbers of any foreigners" come to live in a country and influence its economy, "then you have to do some rethinking as to whether it is good or bad, or the limits that you have to impose on them."

During their meeting in the afternoon, Duterte and Mahathir vowed to ensure the freedom of navigation in the South China Sea, where China has built seven artificial islands with military infrastructure. China routinely slams the U.S. for sailing into the disputed area, where Philippines and Malaysia also lay territorial claims.

Mahathir also pledged to support the fight against terrorism under a trilateral security cooperation with Indonesia that was forged in June 2017 amid a five-month siege by Islamic State-related militants in southern Philippines.

The Malaysian leader congratulated the Duterte administration for the recent plebiscite, which resulted in the creation of Bangsamoro, a new autonomous region in the country's troubled south. Kuala Lumpur has been a facilitator in the peace talks.

Both leaders also discussed boosting two-way trade and partnerships in health and education, but sidestepped the territorial dispute over Sabah, which Malaysia regards as part of its Northern Borneo region.