Carter was slated to become an unrestricted free agent after this season.
"Jeff's experience and versatility have made him a valuable addition to our team," Penguins general manager Ron Hextall said in a statement. "In addition to his on-ice contributions, his team-first attitude has made him a leader inside our locker room and we are happy to have him under contract for two more years."
The 37-year-old from London, Ont., has scored 26 points (12 goals and 14 assists) in 36 games this year. He arrived in Pittsburgh last season in a deadline deal with the Los Angeles Kings.
Carter has 411 goals and 377 assists for 788 points in 1,130 career games with the Philadelphia Flyers, Kings and Penguins. He captured the Stanley Cup with Los Angeles in 2012 and 2014 and won Olympic gold with Canada at the 2014 Sochi Winter Games.