Sean Doolittle, right, with catcher Bruce Maxwell, comes from Oakland along with Ryan Madson to boost the Nationals’ bullpen. (Stan Szeto/USA Today Sports)

For months, a deal to repair the Washington Nationals’ broken bullpen seemed inevitable, and Sunday, after months of frustration and speculation, they finally made one. The Nationals acquired right-hander Ryan Madson and left-hander Sean Doolittle from the Oakland Athletics in exchange for Blake Treinen, left-handed pitching prospect Jesus Luzardo, and 2016 second-round pick Sheldon Neuse.

The move immediately adds two experienced relievers to the Nationals’ bullpen for the rest of this season and at least all of next, though the team will have a club option for Doolittle in 2019 and 2020, too. In other words, this is not just a patch — it is a legitimate upgrade around which the Nationals can build next season, too.

“That’s always important for us,” Nationals General Manager Mike Rizzo said. “Last year, we did a rental deal with [Mark] Melancon that worked out great for us. He was terrific. But it’s often nice if at all possible to get guys who will be with you for a while. It makes the sting of trading off prospects a little easier to handle.”

[Career statistics for Ryan Madson and Sean Doolittle]

Rizzo said initial talks with the Athletics centered on one of the two relievers for a couple weeks before expanding over the previous day. The price the Nationals paid for both signals an unprecedented willingness to absorb salary at the trade deadline.

While the Nationals paid Melancon the rest of his 2016 salary after they acquired him at the deadline, they will now owe Madson the rest of his $7.5 million, as well as the $7.5 million he will make in 2018. Doolittle, meanwhile, is owed the remainder of his $2.6 million salary for this season, $4.35 million in 2018 and would be owed $6 million in 2019 and $6.5 million 2020.

In other words, the Nationals are adding around $5.6 million in prorated salary this season, while also committing to nearly $12 million next year. While the package they sent to Oakland is undoubtedly substantial, it likely would have required one of the Nationals’ elite prospects — Erick Fedde, Juan Soto or Victor Robles perhaps — to get the Athletics to chip in any additional money to surrender two quality relievers under team control beyond 2017.

Blake Treinen pitches in the eighth inning against the New York Mets on July 4. (Jonathan Newton/The Washington Post)

The centerpiece of the package is Treinen, the enigmatic right-hander who perplexed the Nationals with a combination of promise and inconsistency. He showed so much promise that they made him their closer to start the season. He then showed so much inconsistency he forced them to remove him from that role and even from high-leverage innings. Teammates, scouts and coaches raved about his 98 mph sinker and said repeatedly he had some of the best stuff on the team. But he struggled to command his arsenal in key situations, especially this season, when the 29-year-old pitched to a 5.73 ERA in 37 appearances with a troubling 1.619 WHIP.

Luzardo, meanwhile, was the Nationals’ third-round choice in the 2016 draft, a first-round talent who fell because of Tommy John surgery but was returning to form (and climbing internal and external rankings) this season. Neuse hit .291 for Class A Hagerstown as a shortstop.

Ryan Madson pitched in the 2015 World Series for the Kansas City Royals and in the postseason for the Philadelphia Phillies from 2008 through 2011. (Sean M. Haffey/Getty Images)

What the Nationals get in exchange is two veterans with long and impressive relief resumes. Madson was on the Phillies’ 2008 World Series team with Jayson Werth and Joe Blanton, and has a 3.40 ERA over 12 big league seasons. After the Nationals faced him in Oakland (and after Ryan Zimmerman hit a game-tying home run against him in an eventual win), Zimmerman called him “an uncomfortable at-bat” and praised his stuff. The 36-year-old is in the midst of a particularly impressive season, pitching to a 2.06 ERA with a .788 WHIP — both of which are better than any reliever in the Nationals bullpen.

“Doggie is a great competitor,” Werth said. “Like [Max Scherzer], he can really lock it in on the field. He’s battle tested and a two-time champion. In the clubhouse and away from the field, he’s someone that’s a real joy to be around. He’s a hoot.”

Doolittle has been injury prone, but when he pitches, he does so well. He missed part of this season with a left shoulder strain, but has a .656 WHIP in 21 1/3 innings and a 3.09 ERA in 254 career appearances. He was a teammate of Zimmerman’s at the University of Virginia in 2005 and is known for being particularly tough on left-handed hitters. This season, for example, lefties are 0 for 23 with 12 strikeouts against him.

“He’s done that for the majority of his career,” Rizzo said. “We like the fact that he can get left-handers and right-handers out and fills up the strike zone and attacks hitters. I think that’s important for both Ryan and Sean. It’s part of the reason they’re so appealing to us.”

Both Doolittle and Madson are considered positive clubhouse presences, the kind of veterans who should slide into the Nationals’ clubhouse and not disrupt it. They will join a bullpen in desperate need of their assistance that will probably look far different when they arrive than it did even earlier this month. Doolittle probably will join Oliver Perez and Enny Romero in the bullpen, as Matt Grace, who has pitched well, is the only left-hander with options. Madson likely will join Matt Albers, Joe Blanton, Austin Adams and Trevor Gott. Either Grace, Gott or Adams will head back to Syracuse when the Nationals activate Edwin Jackson to start Tuesday’s game.

Once Shawn Kelley and Koda Glover return, the Nationals can build a bullpen with seven of eight (or eight of eight, in the playoffs) of Doolittle, Romero, and Perez from the left side, and Madson, Albers, Blanton, Kelley and Glover from the right. They also could continue to add.

“I think we’ve done what we came to do at the trade deadline,” Rizzo said. “That’s not to say that we’re going to stop scouting. As we’ve shown in the past, if there’s an opportunity to improve the ballclub, we’ll certainly continue to be aggressive and try to help us out any way we can.”

Whatever the Nationals do or do not do from here, they have made the big deal, chocked up the cash fans grumble for and added to the bullpen that has desperately needed help all season. Who will close is, for now, unclear. Dusty Baker has been mixing and matching and now has more options from which to choose. But the bullpen is better today than it was yesterday, and the Nationals playoff prognosis has improved along with it.

Jorge Castillo in Cincinnati contributed to this report.

More Nationals:

Zimmerman is struggling, sure a surge is right around the corner

Nats score enough to avoid another bullpen disaster, hang on to beat Reds

Five questions for the second half, starting with one about the bullpen

More Nats | MLB News | Post Sports | Post Sports on Facebook