The Nationals and all-star right-hander Jordan Zimmermann came to an agreement on a two-year contract extension, a concession after they could not strike a deal on a long-term contract that would prevent Zimmermann from testing free agency after the 2015 season.

Zimmermann signed a two-year, $24 million deal in order to avoid arbitration both this season and next winter. The deal buys out Zimmermann’s final two seasons of arbitration eligibility, but Zimmermann can still become a free agent in two years, same as before Friday’s agreement.

The sides had been “working on a long-term deal” this week, Zimmermann said, but were “too far apart to get that done.” The Nationals presented the two-year option instead a few days ago, and Zimmermann’s agent worked out the smaller deal.

“I’m definitely happy,” Zimmermann said. “I think this means I can just focus on playing baseball and trying to win a World Series.”

The two-year contract seems to make a long-term extension less likely, but it will not preclude Zimmermann from signing a long-term deal before he reaches free agency.

“If a year down the road or after this season if there’s a long-term deal that works out for both sides, we’d be happy and willing to do it,” Zimmermann said. “This is just a small little deal that takes us away from the arbitration. Now I can focus on baseball and not have to worry about the other stuff.”

Zimmermann and the Nationals also discussed a long-term contract last year before spring training. Through all the back-and-forth of negotiation, the sides remained amicable. Zimmermann thanked assistant general manager Bryan Minniti, GM Mike Rizzo and the Lerner family for getting the deal finished.

“They’ve been honest the whole time,” Zimmermann said. “There was never any hard feelings or anything like that. They were respectful and honest, told us what they wanted. And we were honest and told them what we wanted. It just didn’t work out. I’m staying in D.C. for another two years. I’m happy about that, and hopefully we can win a World Series.”

The Nationals could still trade Zimmermann after next season, but the structure of his contract adds a small hurdle. Zimmermann will make $7.5 million in 2014 and $16.5 million in 2015, which means that any team trading for him after this season will take on an exorbitant salary.

Zimmermann, a homegrown 27-year-old, has become one of the best pitchers, posting a 3.10 ERA over 409 innings the past two seasons. He made his first all-star team last year.