The U.S. secretary of transportation said late Thursday that he has reached a final deal with the major stakeholders on financing the second phase of Metro’s Dulles rail line.

After months of negotiations, Secretary Ray LaHood said he had come to an agreement with Fairfax and Loudoun counties, the Metropolitan Washington Airports Authority, Metro and Virginia.

The resulting memorandum codifies how partners in the project will pay for the second phase of the Dulles line, which will extend rail service from Reston to Dulles International Airport and Loudoun.

The project, estimated to cost at least $2.8 billion, will be paid for with contributions from all the major stakeholders.

“I’m on cloud nine,” LaHood said. “After months of very hard work with an extraordinary group of people from the counties, Metro and MWAA, we have put together what I believe is one of the best agreements for taxpayers.”

The deal still needs the approval of the stakeholders’ governing boards. But federal transportation officials said they expect that to occur before the end of the year.

The most important part of the deal is that LaHood’s office agreed to provide federal loan assistance to help Fairfax, Loudoun and the airports authority finance their investment in the project.

LaHood said Virginia Gov. Robert F. McDonnell (R) also agreed to bring $150 million to the table to help finance the project.

“I’m really pleased we were able to keep the project under $3 billion and that we were able to put some additional federal dollars into the project,” LaHood said. “Virginia realized this project is important to Northern Virginia and most important to the region.”

The state and federal money, officials said, will reduce the amount that users of the Dulles Toll Road will have to contribute, although it remained unclear how much tolls will increase. Some toll revenue is being used to help pay for the rail line.

The Dulles rail line will run for 23 miles. The first phase, 11.5 miles, is under construction and is scheduled for completion in December 2013. It runs through Tysons Corner to Wiehle Avenue.

Funding of the second phase was up in the air for months.

The airports authority and local politicians also had argued over whether the station at Dulles Airport should be built below ground, at a higher price, or above ground, for less. They ultimately agreed to put the station above ground, a decision that is expected to save more than$400 million.

This summer, LaHood stepped into the negotiations. He and his top-level staff spent about five months in negotiations with the stakeholders. The deal reached Thursday also solidifies most of the other elements the players had agreed to earlier.

Fairfax and Loudoun plan to seek public-private partnerships to help pay for building parking garages.

Fairfax will seek a similar deal to build the Route 28 station.