Fans exit a rail car at the Navy Yard Metro Station on opening day of the Nationals ballpark on Sunday, March 30, 2008. (Nikki Kahn/THE WASHINGTON POST)

The Nationals are going to the playoffs, and now fans know how they will get home.

Metro announced Thursday afternoon that LivingSocial, the daily deals company based in the District, will fund extended Metro service for any playoff game that ends late.

The announcement, made at the Navy Yard-Ballpark Metro station near Nationals Park, ends weeks of uncertainty over how fans would make it home if playoff games run past Metrorail’s normal closing time.

Even as the Nationals clinched a playoff spot and fought for a division title, the standoff over who should pay for extended service dragged on, with little sign that the District, the Nationals or Metro was willing to budge.

But LivingSocial contacted Metro this week to see whether the company could pick up the bill for extra service. A deal was finalized in the hours before Thursday’s late-afternoon news conference.

“People won’t have to worry about how they’re getting home,” LivingSocial’s founder and chief executive, Tim O’Shaughnessy, told reporters.

Under the agreement, which is like those for other events that begin early or run late, LivingSocial will put down the $29,500 deposit required by Metro to keep the trains running for an extra hour.

In announcing the deal, O’Shaughnessy was joined by representatives from Metro and the Nationals.

Metro General Manager Richard Sarles praised LivingSocial as a great local company and thanked it for reaching out to the transit agency. Gregory McCarthy, vice president of the Nationals, called the agreement “win-win-win” for the fans, the city and the organizations involved. “We want you to stay as late as you like,” he said of fans.

LivingSocial is part of a wave of technology companies that have set up shop in the District in recent years, and this summer the D.C. government agreed to nearly $33 million in tax incentives to keep LivingSocial in the city. (O’Shaughnessy is a son-in-law of Washington Post Co. Chairman Donald E. Graham’s.)

The Capitals and the Redskins, along with the Nationals and numerous other event organizers, have paid for the late-night service in the past.

When asked why the Nationals didn’t put up the money like other sports teams and organizations have, McCarthy said the team wanted more partners involved.

Joe Drugan, managing editor of the Nats Blog, called the decision great for LivingSocial as well as for the team. LivingSocial gets goodwill and positive press, and the Nationals found someone to foot the bill without letting this debate last any longer, he said.

“As long as they came up with a solution, it doesn’t matter what the solution is,” Drugan said.

The deal covers up to two hours of extra service for rides beginning at Navy Yard after weeknight games in October and November.

The first hour is technically from 11:20 p.m. to 12:20 a.m. because the last train connecting to other lines leaves Navy Yard at 11:20 p.m. If the game is still going at 11:45 p.m., the second hour is automatically triggered, Metro spokesman Dan Stessel said.

The prospect of thousands of stranded playoff fans came into clear focus last month when a rain-delayed, 13-inning victory over the Atlanta Braves concluded after midnight, forcing some fans to leave before the game ended and stranding others at the ballpark.

At the core of the uncertainty was the $29,500 deposit Metro requires for an extra hour of service. Event organizers need to put down the refundable deposit and sign an agreement in advance to extend Metro’s hours.

But no one wanted to pay up. The Nationals, who paid to keep Metro open late after a Sunday night game this season against the Phillies, reportedly asked the District to pay for future Metro service; the team was shot down.

This week, Virginia Gov. Robert F. McDonnell (R) and a spokesman for Maryland Gov. Martin O’Malley (D) indicated that they would be open to having their states pitch in some of the money.

McDonnell issued a statement shortly after the agreement was announced, praising the deal as an ideal model of partnership between the public and private sectors.

It could turn out to be a very sweet deal for LivingSocial. The company not only is earning goodwill, and it also may not end up spending much on train service.

That’s because Metro refunds as much of the deposit as the transit agency takes in in fares during the extended service. And Metro’s fare increase, which went into effect in July, makes it even easier for event organizers to recoup their deposit. The transit agency began returning $5.36 a ride, a significant increase over the old rate of $3.62 a trip.

Under the old fare rates, it took 8,150 rides for an organization to make its deposit back. Now, the third party needs only 5,504 fans to ride Metro after a late game at the 41,222-seat Nationals Park to recoup the deposit. So with standing-room only crowds expected for the city’s first baseball playoff games almost 80 years, LivingSocial could end up spending little.

Verizon Center saw just this week how inexpensive such extended service can be — if patrons take Metrorail home. Metro stayed open late on Sunday and Monday nights to help fans get home after Madonna’s concerts at Verizon Center. The agency reported that 5,229 rides were taken during the extra hour after Sunday night’s show and that 5,225 rides were taken after Monday’s concert.

The venue was refunded $28,028 for Sunday night’s performance and $28,006 for Monday night’s show. The total cost for extending service on both nights wound up being $2,966, or just under $20 for each minute between the Sunday concert’s announced start time (8 p.m.) and its actual start time (10:30 p.m.).