Malaysia has been an important ally for China. Its prime minister, Mahathir Mohamad, was among the first foreign leaders to sign up to its coming Belt and Road Summit, a lavish two-day affair. The United States said this month that it would not send high-level officials to the conference, on concerns about the financing behind the plan.

But even for Malaysia, the original price tag for the rail deal with China Communications Construction Company was too much to stomach. The new administration saw the splashy Chinese infrastructure projects like the East Coast Rail Link and a $2.5 billion gas pipeline deal as opportunities for corrupt senior politicians to plunder government coffers.

When Malaysia signed the agreement for the rail line, the Chinese state-backed company was under a World Bank ban for doing certain kinds of work because of a corruption scandal in the Philippines. Mr. Mahathir cited Sri Lanka’s experience to justify his decision to suspend the East Coast Rail Line project.

Mr. Mahathir, 93, came out of political retirement last year, riding a groundswell of opposition to the prime minister at the time, Najib Razak, amid allegations of large-scale corruption.

At the heart of the scandal was a state investment fund called 1Malaysia Development Berhad, or 1MDB. Officials and prosecutors have called 1MDB a slush fund, alleging that Mr. Najib siphoned hundreds of millions of dollars at the expense of the Malaysian people. (He went to trial last week in what is expected to be the first of multiple corruption trials.)

After taking over from Mr. Najib last spring, Mr. Mahathir’s administration discovered the country was in worse financial shape than previously understood. A $170 billion debt pile turned out to be closer to $250 billion, amounting to 80 percent of Malaysia’s gross domestic product at the time.

As the new government began to pare back the debt, Mr. Mahathir announced that the administration would halt the East Coast Rail Link project and the gas pipeline deal, citing the high costs.