DeMar DeRozan is staying put in Toronto with a five-year 139 million dollar deal, which is the second highest contract in NBA history. (1:29)

All-Star shooting guard DeMar DeRozan has agreed to re-sign with the Toronto Raptors, according to ESPN's Brian Windhorst and multiple reports.

The structure of the contract is still being worked out, but it's expected be for five years and average $29 million per season, a source said.

DeRozan expressed a desire to return to Toronto after the Raptors were eliminated from the playoffs, and a source told ESPN's Tim MacMahon in late June that the shooting guard was focused on re­-signing with the team, rather than setting up meetings with others once free agency started.

Toronto general manager Masai Ujiri also said retaining the veteran swingman was the team's No. 1 goal.

The Raptors are the only franchise DeMar DeRozan has played for in his seven-year NBA career. Steve Russell/Toronto Star via Getty Images

The two-­time All­-Star averaged 23.5 points per game during the regular season in 2015-­16. He has played his entire career with the Raptors, who selected him No. 9 overall in the 2009 NBA draft.

DeRozan, 28, grew up in Los Angeles and attended Compton High School and USC. Toronto is coming off its most successful season, in which it advanced to the Eastern Conference finals for the first time in franchise history.

Information from the Undefeated's Marc Spears and ESPN's Mike Mazzeo was used in this report.