Malaysia's Prime Minister Mahathir Mohamad. Lai Seng Sin, Reuters/file

Malaysian Prime Minister Mahathir Mohamad confirmed Tuesday the cancellation of two major Chinese government-backed infrastructure projects in his country worth over $20 billion, including a railway and two gas pipelines.

At a press conference in Beijing before ending his five-day visit, Mahathir said Malaysia, owing to its financial woes, cannot afford the projects, namely the $20 billion East Coast Rail Link for which construction already started, and the Trans-Sabah Gas Pipeline projects worth over $2 billion.

"At the moment, the priority is for us to reduce our debt. With that debt if we are not careful we can become bankrupt. That is the work of Najib," he said, referring to his predecessor Najib Razak.

The rail project, launched last year and slated for completion in 2024, was one of the showpiece infrastructure projects under China's Belt and Road Initiative.

It would have connected ports facing the South China Sea on the east coast of peninsular Malaysia to ports on the Straits of Malacca on the west coast over a distance of 688 kilometers.

Some 85 percent of the financing was being provided through a 20-year loan at 3.5 percent interest from the Export-Import Bank of China.

Mahathir had earlier taken issue with the loan condition that the contract be given to a Chinese company, using its own workers with everything brought from China.

On Tuesday, he said, "My job is to establish principles that investment in Malaysia is not about bringing in workers and all that. It is about bringing in capital and technology, not workers. We want our people to be employed."

In June, it was learned that the Malaysian government had already spent 20 billion ringgit ($4.8 billion) on the project. It was suspended in July after being 13 percent completed.

Mahathir said Chinese President Xi Jinping and Premier Li Keqiang accepted his reasons behind the cancellations.

"Initially, there were some misunderstandings, but now they understood why we do it. I don't think China wants us to be bankrupt," he said.

"It is all about borrowing too much money...which we cannot repay and also because we do not need those projects in Malaysia at this moment. Maybe later on, yes. But now we do not need it."

Mahathir lamented that Malaysia may have to pay "huge sums of money" in compensation, while he slammed Najib's "stupidity" for negotiating deals that lack "fair" exit clauses.

"Such stupidity has never been seen in the history of Malaysia," he said. "You cannot blame the Chinese for that."

Mahathir also reiterated Tuesday that he does not see the necessity of moving forward now with a high-speed rail project connecting Malaysia and Singapore, which was mooted by the previous administration.

The proposed 360-kilometer rail line that would stretch along the west coast of the Malay Peninsula, from Kuala Lumpur to Singapore, is among a number of big-ticket projects that came under review in the aftermath of his return to power in May.

Scrapping the high-speed rail project, however, would cost the Malaysian government a potential penalty of 500 million ringgit for breaking the agreement with Singapore.

Mahathir, who previously served as prime minister for 22 years until 2003, has focused on cutting down government expenditure in his second turn in office in order to trim the national debt of almost 1 trillion ringgit, or about 65 percent of the gross domestic product.