President Donald Trump said Tuesday that the federal government will not pay for California’s high-speed train, another obstacle in a project that has repeatedly blown past its budget and completion timeline since voters approved funding in 2008.

“That train is the worst cost overrun I’ve ever seen,” Trump told reporters in the Oval Office during a joint appearance with Prime Minister Mark Carney of Canada. “It’s, like, totally out of control.”

He added: “This government is not going to pay.”

The president’s comments came three months after his administration started a review of how California is spending a $3.1 billion federal grant issued under the Biden administration.

The project was originally envisioned as a $33 billion bullet train that would, by 2020, whisk people between San Francisco and Los Angeles in less than three hours. But plans have been stymied by inflation, lawsuits over land acquisitions and lengthy environmental reviews, along with repeated tussles over funding.

As of this year, only part of the first segment — a 171-mile stretch from Merced to Bakersfield — has been built. That section is now slated for completion between 2030 and 2033, and it alone is estimated to cost $35 billion. Completing the entire 494-mile project could cost between $88 billion and $128 billion, according to the latest estimates from the agency planning and building the project, the California High Speed Rail Authority. It could be decades before that is finished.

In January, Gov. Gavin Newsom visited Bakersfield in January to tout progress on the project.

“With 50 major structures built, walking away now as we enter the track-laying phase would be reckless — wasting billions already invested and letting job-killers cede a generational infrastructure advantage to China,” Izzy Gardon, the governor’s spokesman, said in response to Mr. Trump’s comments.

Federal funding is needed to complete the Central Valley segment. The authority had aimed to receive $8 billion in funding from the Bipartisan Infrastructure Law between 2023 and 2028 to help build the stretch.

Funding for the project changes with each administration. During his first term in office, Trump canceled $1 billion in federal funding that had been promised to the project, saying at the time that “the cost overruns are becoming world-record setting.”

California sued, and got the money back through a settlement reached with the Biden administration in 2021. This latest funding hurdle is also likely to end up in court.

In 2023, the authority was awarded $3.1 billion in grant funding from the Biden administration to help fund continued construction in the Central Valley.

The rail authority has said that continued uncertainty over the rail’s funding is a major reason for the delays.

Many in California still consider the train the most important clean transportation project the state has ever embarked on.

In 2023, Newsom rode China’s high-speed rail on a visit to that country, highlighting the possibilities of the technology as the train whizzed through the countryside on the way to Shanghai.

A spokesperson for the California High-Speed Rail Authority said the project has resulted in 15,000 construction jobs and is delivering results, “despite the noise in Washington.”

Trump’s remarks Tuesday are perhaps unsurprising, given the disdain he’s already expressed for the train. In February, he suggested that California could save “hundreds of billions” by providing “the finest limousine service” for people traveling between San Francisco and Los Angeles rather than finishing the rail line.

The president mocked Mr. Newsom on Tuesday by calling him “Gavin Newscum.” Mr. Trump said that while he’d like to see Mr. Newsom run for president, he believes the governor’s political future is doomed because of the delays in the train project and the devastation from the Los Angeles wildfires earlier this year.

Newsom’s spokesman fired back by calling Trump “the self-described ‘King of Debt’ who ran a steak company, a casino, and a global economy — all into the ground.”

A majority of Californians still express optimistic about the train, with 54% of respondents in a recent Emerson College poll of state voters saying the project remains a good use of state funds.

Reporter Kate Talerico contributed to this story.