Hamlin agreed to the extension even though his current deal was not set to expire until the end of the 2013 season.
"If I'm going to win a championship, I'm going to do it with Joe Gibbs Racing," Hamlin said. "They worked hard with me to get the deal signed. I'm lucky to have a team and sponsor (Fed Ex) who want to be with me."
Hamlin, 31, has 19 wins in the Sprint Cup Series in nearly seven full seasons with JGR. He has finished as high as second in the series standings, in the 2010 season. He also has 11 wins in the Nationwide Series and one in the Truck series.
So far this season Hamlin has a pair of Cup wins and is eighth in the series standings entering Saturday night's Quaker State 400 at Kentucky Speedway.