The Toronto Maple Leafs and restricted free-agent winger Mitch Marner have agreed to a six-year deal, sources told ESPN, ending one of the most controversial negotiations of the NHL offseason.

Marner’s deal carries a $10.893 million average annual value against the salary cap, sources confirmed. That makes the 22-year-old the third highest paid member of the Leafs via the cap, behind centers Auston Matthews ($11.634 million) and John Tavares ($11 million). Marner’s cap hit is the seventh highest in the NHL among all players, and is second only to New York Rangers free agent signee Artemi Panarin ($11,642,857) among wingers.

TSN was first to report the average annual value of Marner’s deal.

Marner had 26 goals and 68 assists for a team-leading 94 points last season for Toronto while skating primarily with Tavares. In three seasons, he has 67 goals and 157 assists, and his 224 points ranked him 22nd overall in that span.

He was drafted fourth overall by the Leafs, his hometown team, in 2015.

The negotiation between the Leafs and Marner was the talk of the NHL during this summer. A slew of other restricted free agent forwards — including Brayden Point of the Tampa Bay Lightning, Matthew Tkachuk of the Calgary Flames and Mikko Rantanen of the Colorado Avalanche — remained unsigned, with some indication that they were waiting on Marner to set the market.

It was a controversial negotiation, too, as Marner’s camp ignored any comparable wingers’ salaries to focus on what Matthews signed for earlier this year. Toronto GM Kyle Dubas went as far as to say that if Marner signed a free-agent offer sheet, there was no guarantee that Toronto would match it. Leaks to the Toronto media from both sides of the table showed a wide gulf between the player and team; especially on term, as the Leafs wanted and eventually won a long-term deal that eats up two unrestricted free agent years for Marner.

With Marner signed, the Leafs are currently $13,365,199 over the NHL salary cap ceiling of $81.5 million, but that’s before Toronto places forwards Nathan Horton, David Clarkson, Zach Hyman and defenseman Travis Dermott on long-term injured reserve, where their cap hits will no longer count towards that number.