New Jersey and New York lawmakers were successful Wednesday in protecting protect $900 million intended to jump start Amtrak's Gateway project, which includes replacing a rail bridge in the Meadowlands and building a new tunnel under the Hudson River.

The funding came under attack from conservatives who contend it violates a 2010 ban on "earmarks," or congressionally mandated spending for specific projects.

The attack failed, with the House voting 159-260 just before 11 p.m. to defeat it. Voting to strip the funding were 155 Republicans and four Democrats, while opposing it were 76 Republicans and 184 Democrats.

Rep. Rodney Frelinghuysen, a Republican from Harding who is chairman of the House Appropriations Committee, was instrumental in getting the $900 million included in the 2018 budget for the U.S. Department of Transportation.

That DOT budget was part of a massive spending package the House took up Wednesday afternoon, and one of the 118 amendments proposed would have redirected the $900 million from Gateway to other projects around the country and to deficit reduction.

Under the earmark ban, Frelinghuysen was blocked from directing the $900 million specifically to Gateway, but he found ways to put it in accounts that left few other options for spending it.

About $400 million was targeted to a line item for projects that serve both intercity railroads — another definition for Amtrak — and commuter lines. NJ Transit, whose commuter trains rely on the tunnel, is a partner with Amtrak on Gateway.

Frelinghuysen's bill also increased from $26 million to $500 million the line item for Amtrak to bring its tracks, bridges and tunnels up to a "state of good repair," money Amtrak presumably could use anywhere.

Groundwork:Road Warrior: The light at the start of the tunnel

Optimism:Outgoing Amtrak boss optimistic Gateway will be funded, but not by private investors

Getting there:Train safety system's installation could cut Penn Station's capacity

To set aside that money, however, the bill said that only transit projects that already had full funding agreements in place could qualify for funding on what is called the New Starts program, essentially cutting off any chance of money for projects that were getting ready to apply, including two light rail extensions in Minneapolis.

The bill also zeroed out what are called TIGER grants, a competitive program for roads, transit or ports for projects nationwide that achieve national priorities.

The 106-year-old Portal Bridge over the Hackensack River needs replacing because it must swing open to allow for ships to pass, and often gets stuck that way, causing train delays. The existing tunnel was heavily damaged by flooding in Superstorm Sandy, and is projected to fail during the coming decade.

An amendment sponsored by Rep. Ted Budd, R-N.C., would restore $400 million to New Starts, while cutting the "state of good repair" funding back to $26 million, essentially blocking any new funding for Gateway. Co-sponsors originally included Rep. Keith Ellison, D-Minn., but he ended up voting against the measure Wednesday night.

"The provision I’m trying to get rid of is a $900 million earmark, about 300 times the size of the average earmark before they were banned,” Budd said. "This isn’t a trivial amount of money. North Carolina and the other 48 states should not have to foot the bill for this hall of fame earmark.”

A conservative group, the Club for Growth, said Wednesday it was urging House members to vote for the Budd amendment and would count it – along with a vote on another amendment to defund Amtrak entirely that was defeated 128-293 – on its annual scorecard. Such scorecards are often used by members to establish their conservative bona fides with local groups, and contributors.

Supporters of the program, however, said it is a national priority to prevent the tunnel's failure because of the economic impact that would result from disrupting traffic on the Northeast Corridor between Washington and Boston and causing gridlock in the New York City region as commuters switch to cars.

"Gateway is not merely some regional issue and stripping these funds would harm our safety, our security, to say nothing of added traffic and transit stress," said Rep. Bill Pascrell, D-Paterson. "While the underlying bill underfunds our nation's infrastructure, there is no question that money provided to update this chokepoint is of utmost importance."

Rep. Leonard Lance, R-Hunterdon County, said that the New York/New Jersey region contributes $3.7 trllion to the gross domestic product.

"Now is the time to be investing in critical national infrastructure priorities across the country," Lance said. "We need to be doing this work now, while interest rates are low, so taxpayers get a better deal on this inevitable work.”

But Budd, who is serving his first term, said that Gov. Chris Christie in 2010 canceled a similar project, a tunnel known as Access to the Region's Core.

"This project costs $4 billion more," Budd said.

The entire Gateway project is estimated to cost nearly $27 billion, and would be built over a decade or more. New Jersey and New York have jointly pledged to cover half the cost, with the other half to come from Amtrak or the federal DOT. There has been no agreement signed, however, on how that money would be raised.

The first phase, which calls for replacing the Portal Bridge for $1.7 billion and building a new tunnel under the Hudson River for $11 billion, could be launched with the $900 million in the House bill.