Pitcher Max Scherzer has agreed to a seven year contract with the Nationals. (Carlos Osorio/Associated Press) (Carlos Osorio/Associated Press)

The Washington Nationals radically altered the baseball landscape Sunday night, ending a winter of relative inactivity by agreeing to a seven-year contract with free agent pitcher Max Scherzer, according to a person with direct knowledge of the talks.

Though terms of the deal weren’t immediately available, it almost certainly will be worth more than the $160 million offer Scherzer turned down last spring, when he was still with the Detroit Tigers. That would make it the richest in franchise history — and make the Nationals prohibitive favorites to win the World Series.

Another official with direct knowledge described the Nationals as “very aggressive,” and while another team seemed to be in the mix through most of Sunday evening, Washington felt good about its chances to land the prize of the offseason class as the night wore on. The deal was described by one source as “complicated,” and it may not be formally announced immediately.

But with the parameters in place, the Nationals stunningly added one of the game’s best pitchers (Scherzer’s 3.24 ERA over the past three years ranked third in baseball) to one of the game’s best rotations (Washington led all of baseball with a 3.04 ERA for its starters last year). And one official with knowledge of the deal indicated that although the Nationals have been willing to trade right-hander Jordan Zimmermann — who has only the upcoming season before he becomes a free agent — the addition of Scherzer doesn’t necessarily mean the Nationals would have to deal anyone to make financial room for Scherzer.

So it’s possible the current roster — which includes the major contributors to the team that won 96 games and the National League East in 2014 — will remain intact. That would give the Nationals an unparalleled rotation of Scherzer, Stephen Strasburg, Zimmermann, Gio Gonzalez and Doug Fister. With rookie Tanner Roark in the rotation last year, the Nationals posted the best ERA in baseball among starting staffs, and as well as Roark pitched, Scherzer would represent a monumental upgrade.

The Nationals’ involvement with Scherzer was first reported by CBSSports.com on Sunday afternoon, and it helped clarify a market for which there had been mostly mystery. All offseason, it has been easy to say the Nationals would remain attached to Scherzer because General Manager Mike Rizzo was the scouting director in Arizona when the Diamondbacks took him with the 11th pick in the 2006 draft.

But the relationship that mattered more here is between Scherzer’s agent, Scott Boras, and Theodore N. Lerner, the Nationals’ principal owner. Boras has long described the pursuit of Scherzer as an “ownership decision,” and Boras did in fact meet with Lerner earlier this month. Boras has done many deals with Rizzo and Lerner — including Strasburg, Jayson Werth, Bryce Harper and Anthony Rendon — and at 89, Lerner may sense the 2015 team represents his best opportunity to bring Washington its first World Series title since 1924.

At various points over the past two months, the teams with baseball’s highest payrolls — the Los Angeles Dodgers, New York Yankees, Los Angeles Angels, Detroit Tigers, San Francisco Giants and Boston Red Sox — have denied they would pursue Scherzer. Tigers President Dave Dombrowski, who offered Scherzer the seven-year, $160­­ million deal he rejected last spring, reiterated that stance Sunday night in an interview with MLB.com.

Rizzo, like most entrusted with constructing rosters, resists long contracts for starting pitchers. Indeed, the history of such $100­ million deals is littered with far more busts than success stories.

So this winter, two facts drove the idea that Washington wouldn’t pursue Scherzer: the excellence of its current rotation and the strong belief throughout the sport that the Nationals aren’t going to grow their payroll going forward. Washington expects to continue to be financially competitive, as it was in 2014, when the team’s opening day expenditures were a little more than $134 million, which ranked ninth in baseball. But the Dodgers and the Yankees both spent more than $200 million last season. This is territory where the Nationals won’t tread.

But Boras is an expert at laying out how a lucrative deal for one of his clients can fit into the overall structure of a franchise’s payroll — now and in the future. Total compensation of $175 million contract — an average of $25 million a year, slightly less than his former teammate Justin Verlander — certainly isn’t out of the question, and the Nationals could figure out how to make it work in one of several ways.

Before the deal, the Nationals had roughly $127 million in salary obligations for 2015, but that covers only 22 players (and estimates reliever Jerry Blevins at $2.3 million, the midway point between the figures the sides exchanged for arbitration Friday). They saved money not only by trading reliever Tyler Clippard but also by allowing free agents Adam LaRoche and Rafael Soriano to walk.

Say the three remaining roster spots are filled by players making near the league minimum of $500,000 — outfielder Michael Taylor or pitcher Blake Treinen would be candidates — the Nationals still would be around $130 million, less than they spent a year ago.

So there are two ways the deal for Scherzer works. The contract could average $25 million a year (or more), but if the Lerner family is concerned about a ballooning payroll in 2015 — upward of $155 million, say — then Boras and Scherzer could easily backload the deal, paying Scherzer perhaps $15 million in 2015 and then higher salaries in future years.

Another option: Sign Scherzer and trade Zimmermann — and his $16.5 million contract — for prospects, serving both the current club and future versions. If Scherzer’s deal was backloaded as described above, then Scherzer’s 2015 salary simply would replace Zimmermann’s and the Nats would end up with a comparable (maybe even better) pitcher for this season. (Scherzer, 30, went 18-5 with a 3.15 ERA and a 1.175 WHIP in 2014 while pitching in the American League; Zimmermann, 28, went 14-5 with a 2.66 ERA and a 1.072 WHIP last year while pitching in the NL. Start the debate.)

If the Nats decided to keep everybody and go into the season as a potential juggernaut — try to pick an opening day starter among Scherzer, Strasburg and Zimmermann — Boras still could argue payroll certainty going forward because the Nationals have so many free agents-to-be. Zimmermann would be gone. Shortstop Ian Desmond (making $11 million this season and likely to receive a $150 million deal as a free agent) could be, too. Take off the salaries of Fister ($11.4 million) and center fielder Denard Span ($9 million) and suddenly Scherzer fits into a team whose payroll, by mere attrition, would fall by nearly $48 million. And it’s clear at this point: There are no substantive discussions about long-term extensions with either Desmond or Zimmermann, two of the Nationals’ homegrown all-stars.

But for now, such negotiations aren’t a concern. After doing next-to-nothing for the first 2 1/2 months of the offseason, the Nationals sent a jolt throughout the sport — a jolt that will make them favorites to win a championship, one that gives them an ace for the foreseeable future.