WASHINGTON — Congress ended weeks of contentious negotiation Tuesday, agreeing to a five-year transportation bill that will boost spending on roads and transit systems by billions of dollars each year.

In its first year, the approximately $300 billion bill increases spending on highways by $2.1 billion above current levels. By the final year, in 2020, the bump will be $6.1 billion above the about $50 billion that has been spent in recent years.

Spending on transit will go from the current $8.6 billion to almost $10.6 billion in 2020.

“I’m proud. I’m relieved. We are in dire need of this,” said Sen. Barbara Boxer, D-Calif., the ranking member of the Senate Environment and Public Works Committee, which provided the fulcrum to get the bill through the conference committee. “It will result in millions of jobs over the period of the bill, and they can’t be outsourced. They have to be done in America.”

The long-sought bill protects funding for transit from those who argued it should be cut loose from the highway bill, increases money for pedestrian and bicycle programs that also have come under attack and it includes nearly $200 million to speed installation of a critical railroad safety feature known as positive train control.

Specifics on how the transportation bill will affect road and bridge projects in Maine were not available Tuesday night, but members of Maine’s congressional delegation reacted favorably to the news.

Maine Sen. Susan Collins, the Republican chairman of the Transportation, Housing and Urban Development Appropriations Subcommittee, said states have long needed predictability so they can plan projects effectively.

Maine Sen. Angus King, an independent, said there have been “far too many short-term patches” in previous transportation policies.

The bill restores what once was the natural order of things in transportation, setting the game plan and funding levels for several years and ending the herky-jerky process of funding extensions that were the order of the day for the past 10 years.

In addition to increasing spending for roads and transit, the bill increases funding for freight transportation and creates a grant program for freight; restricts rental car leasing of recalled vehicles; bumps up to $295 million the cap on liability claims faced by railroads; triples the amount that the National Highway Safety Administration can level in civil fines; and continues the popular Transportation Infrastructure Finance and Innovation Act (TIFIA) program. It also includes a measure that reauthorizes the U.S. Export-Import Bank.

The bill is a landmark moment for a Congress that is reviled by many Americans as a do-nothing body, most notable for the bitter fighting between its most extreme elements. But even in this week’s success, there is failure. Once again, the lawmakers have not found transportation’s holy grail, a renewable source of cash to fund the nation’s needs.