Evgeni Malkin has agreed to a four-year contract extension with the Pittsburgh Penguins on the eve of NHL free agency, ending a tumultuous week between the star center and the team.

Malkin, 35, will earn $24.4 million over four years for an average annual value of $6.1 million.

“Evgeni is a generational talent who will be remembered as one of the greatest players in NHL history,” Penguins general manager Ron Hextall said Tuesday night in a statement. “His hockey resume and individual accomplishments speak volumes about him as a player, and we are thrilled to watch him continue his remarkable legacy in Pittsburgh.”

Malkin has spent all 16 years of his career with the Penguins. Along with center Sidney Crosby and defenseman Kris Letang, he was a core player who helped Pittsburgh win the Stanley Cup three times. Malkin won the Hart Trophy as NHL MVP in 2011-12 and the Conn Smythe Trophy as playoff MVP in 2009. He has 1,146 points in 981 games with Pittsburgh.

Malkin had 20 goals and 22 assists in 41 games for the Penguins this past season, and then six points in seven playoff games.