Around the time on Monday night when news broke that Anthony Barr would be leaving Minnesota for the New York Jets, the Vikings placed a call to Barr’s agent, Brian Murphy, for a conversation that offered them a sliver of hope.

Barr, Murphy informed the Vikings, was having second thoughts about the deal he was set to sign in New York (which would have paid him around $15 million a year and made him a featured pass rusher in the Jets’ 3-4 defense). As appetizing as the offer seemed, Barr decided on Monday night to sleep on it before Murphy would take the steps to turn the linebacker’s verbal agreement into an official deal.

While the 26-year-old linebacker cleared his head, the Vikings and Murphy worked. By late Tuesday morning, they had the latest in their long history of deals together, having hammered out a five-year agreement that would pay Barr like a premier pass rusher while rewarding him for the unique role he’d carved out in Mike Zimmer’s defense.

The deal, worth $67.5 million, includes $33 million in guaranteed money, according to an NFL source.

Instead of heading to New York as a pass rushing linebacker, the four-time Pro Bowler became the second free agent in as many years to spurn a larger offer from the Jets, following what Kirk Cousins did last year. Though his deal includes up to $10 million in incentives, he’ll return to a team that has used him in a varied role, where he’s charged as much with occupying blockers’ attention before dropping into coverage as he is with chasing down quarterbacks and racking up the kinds of statistics that often trigger incentives and larger accolades.

In accepting a late offer to stay with the team that drafted him, though, Barr delivered a surprising conclusion to a story that seemed fated for a different end, and kept the Vikings from losing both of their big defensive free agents, hours after defensive tackle Sheldon Richardson reportedly agreed to a three-year, $36 million deal with the Browns.

“It’s been a crazy couple days, but I’m where I want to be,” Barr wrote on his Instagram page. “I believe in our locker room. I love my guys! Back to work!”

Barr will get a chance to finish what he started with the Vikings after five years where he flashed dominance on an intermittent basis, posting 13½ sacks, 22 pass defenses, seven forced fumbles, four fumble recoveries and one interception.

The Vikings gave Barr some work with their defensive linemen during training camp last year, in an effort to refine his pass-rushing skills under position coach Andre Patterson’s tutelage; he posted all three of his sacks in December, and finished the year as the NFL’s most productive pass-rushing linebacker based on how frequently he pressured the quarterback, according to Pro Football Focus.

The Vikings began talks about an extension for Barr last season, before opting to put discussions on hold for the 2018 season. While the Vikings worked out deals for Eric Kendricks, Danielle Hunter and Stefon Diggs, Barr bided his time. The Vikings talked with Murphy again at the combine, though the agent informed the Vikings that Barr wanted to test out his market in the NFL’s negotiating window that opened on Monday.

He did so with the Vikings in close contact, and with Zimmer making it clear how much he wanted the linebacker to return.

Now, the Vikings will need to clear cap space quickly to afford Barr and attend to their other needs.

They had less than $8 million in available space on Tuesday morning after agreeing to a three-year, $12.45 million deal with defensive tackle Shamar Stephen.

Defensive end Everson Griffen, whose $10.9 million base salary for 2019 becomes fully guaranteed Friday, remained the most obvious candidate for a restructured contract; sources said the Vikings have submitted an offer to the defensive end that would rework the final four years of his deal and help the team clear cap space.