Free agent center David Desharnais has agreed to a one-year, $1-million contract with the Rangers, who have been searching for a third- or fourth-line pivot to play behind Mika Zibanejad and Kevin Hayes.

Desharnais, 30, who played for the Canadiens and Oilers last season, appears to be one answer to the question of depth, presumably as a replacement for Oscar Lindberg, who was selected by Las Vegas in the expansion draft. The Rangers confirmed the transaction Tuesday.

advertisement | advertise on newsday

The lefty, who is 5-foot-7 (about the same size as winger Mats Zuccarello) and five years older than Lindberg, had just four goals and six assists in 31 games in Montreal last season. A knee injury forced him to the sidelines in mid-season, and he was later traded to Edmonton, where he was 2-2-4 in 18 games, and 1-3-4 in 13 playoff games. The post-season goal was an overtime winner against San Jose.

After going undrafted, Desharnais (pronounced DAY-AHR-NAY) signed as a free agent with the Canadiens and spent parts of eight seasons in Montreal, appearing in in 435 games, scoring 79 goals and totaling 171 points. In his career, Desharnais, who had a $3.5 million salary cap charge last season, has won 50.5 percent of his faceoffs.

General manager Jeff Gorton traded center Derek Stepan to Arizona, along with goalie Antti Raanta, to get the No. 7 pick in the draft (Lias Andersson) and 21-year-old defenseman Anthony DeAngelo, but also freed up needed cap space. The space was essentially used to help pay for defenseman Kevin Shattenkirk and goalie Ondrej Pavelec.

Gorton now has about $7.3 million in cap room, including defenseman Kevin Klein’s $2.9 million charge. If Klein decided to retire from the NHL or play in Europe, the Blueshirts would have $10.2 million.

advertisement | advertise on newsday

Gorton needs to sign Zibanejad and Jesper Fast and has mentioned the possibility of switching winger J.T. Miller to center. The team also will give Andersson and prospect Cristoval Nieves looks at center in training camp in September.