Gateway had built bipartisan support among representatives of New York and New Jersey and received the blessing of former President Barack Obama. The two states had pledged to cover half of the cost of the most critical parts of the project — the tunnel and improvements along Amtrak’s rail line between New York City and Newark. Those segments have an estimated cost of more than $11 billion.

But the Trump administration reversed course late last year and declared that there was no agreement for the federal government to provide the other half of the funding. Mr. Trump pressed House Speaker Paul Ryan, a fellow Republican, to leave any money for Gateway out of the spending bill that Congress is completing this week, according to people with knowledge of the conversations.

That stance angered some Republicans from the region who had stumped for the project, including Representative Rodney Frelinghuysen from northern New Jersey and Representative Peter King from Long Island. Mr. King had vowed to vote no on a spending bill that failed to fund Gateway.

Congressional aides said that the latest draft of the spending bill included about $540 million in allocations that could be used on Gateway and about $2.9 billion in grants to the Department of Transportation that Gateway’s planners could apply for. The project’s supporters are wary about the chances of receiving discretionary funding because the secretary of transportation, Elaine Chao, has opposed the notion that the federal government should supply a significant portion of the project’s funding.

Gov. Philip D. Murphy of New Jersey, a Democrat, said in an interview on Wednesday that Gateway “is too important to not get funded.” But he was reluctant to celebrate prematurely, saying only that he was hopeful. Senator Charles E. Schumer, the Democratic leader from New York who has been a vocal supporter of Gateway, declined to comment.