The 42-year-old has spent the entirety of his Cup career with Gibbs since he made his debut at the top level in 2005, winning 50 of his 641 race starts.
Hamlin's deal with JGR was due to expire at the end of this season, and he revealed last month that negotiations had been delayed in part by his involvement as a co-owner in rival Cup squad 23XI Racing, which currently has a technical alliance with JGR.
"If I didn’t own a team, I think it would be done by now," he said.
But after much speculation and delay, JGR announced on Monday that his contract extension had been agreed, while Hamlin confirmed on his podcast that the relationship between 23XI and JGR will remain unchanged.
”It is amazing to think it has been almost 20 years since J.D. [Gibbs] first saw him race and we signed him to that first contract,” said Joe Gibbs, owner and founder of JGR.
”He has been a big part of Joe Gibbs Racing ever since then and we look forward to that continuing for years to come.”
Hamlin has never won a Cup title, with a best result of second in 2010, but he has reached the winner-takes-all Championship 4 playoff in four of the last nine years.
A three-time winner of the Southern 500 at Darlington, Hamlin also won the 2022 Coke 600 at Charlotte. He is tied with Junior Johnson as the most successful driver in Cup history without a driver's title.
”Joe Gibbs Racing has been my home for almost 20 years now,” said Hamlin in a release from the team.
”My relationship with Joe [Gibbs], my team, and everyone at JGR means a lot to me. We have accomplished so much together over the years. I’m excited to finally announce this so we can put all our focus on chasing the championship.”
Hamlin is competing in the Cup playoffs for the 17th time in his career, having won two races so far this year.
Earlier this year, Hamlin's team-mate and 2017 Cup champion Martin Truex Jr. revealed that he will return in 2024 after rumours that he might retire.