The Lightning sent defenseman Matt Walker and a 2011 fourth-round draft pick to Philadelphia in return, the team said.
"With his combination of speed and skill we are excited to have him with us," Tampa Bay general manager Steve Yzerman.
Gagne had played his entire 664-game NHL career with the Flyers, recording 259 goals, including 47 game-winners, and a total of 524 points.
"I'm very excited right now," twice NHL All Star Gagne told reporters. "I'm looking at this opportunity as a new challenge and a new start."
Gagne has reached the playoffs in nine of his 11 seasons, scoring 32 goals and posting 47 points from 90 career postseason games.
The 30-year-old Quebec native shined in Philadelphia's march to the Stanley Cup Finals last season, recording nine goals and 12 points in 19 games.
(Writing by Larry Fine, Editing by Steve Ginsburg)