Financial terms of the deal were not announced by the Lakers, but ESPN Los Angeles reported that Bryant will remain the NBA's highest-paid player.
Bryant, who is recovering from a torn Achilles tendon, will make $30.4 million this season before the extension kicks in.
"This is a very happy day for Lakers fans and for the Lakers organization," general manager Mitch Kupchak said in a statement. "We've said all along that our priority and hope was to have Kobe finish his career as a Laker, and this should ensure that that happens.
"To play 20 years in the NBA, and to do so with the same team, is unprecedented, and quite an accomplishment. Most importantly, however, it assures us that one of the best players in the world will remain a Laker, bringing us excellent play and excitement for years to come."
Bryant is a 15-time All-Star who has won five NBA championships and two MVP awards. He has averaged 25.5 points, 5.3 rebounds and 4.8 assists for his career. However, he has not played since the Achilles tendon injury in April. He recently returned to practice but there is no timetable on when he will return to game action.