The Lakers did not announce financial terms, but a source told ESPNLosAngeles.com's Ramona Shelburne that the deal is worth $48.5 million.
Bryant, 35, will maintain his status as the NBA's highest-paid player over the course of the extension, the source told Shelburne. The 2007-08 league MVP will receive $23.5 million in the first year and $25 million in the second year of the extension, according to the source.
The Lakers and Bryant arrived at the salaries so that the team will have the financial flexibility to pursue one top free agent on the market next summer, the source told Shelburne.
Bryant and 39-year-old point guard Steve Nash are the only players signed to significant contracts for next season with the Lakers, who have been anticipating a major roster restructuring in 2014 since Dwight Howard fled town in July.
Even if the Lakers waived the oft-injured Nash under a special provision limiting his salary cap hit, Bryant would eat up roughly a third of the team's room under the projected cap before anybody else joins him next season.
Bryant, who has not played since suffering a torn Achilles tendon in April, will make more than $30.4 million this season, the final year of his current contract.
The source also said the Buss family was unified in wanting to see Bryant continue to be the league's highest-paid player, and that the owners wanted the extension finalized before Bryant's return to the court as a way of demonstrating his importance to the franchise.
The team announced the deal in a news release, saying the signing "should ensure" that Bryant finishes his storied career with the Lakers.
"This is a very happy day for Lakers fans and for the Lakers organization," general manager Mitch Kupchak said in the release. "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, who has helped the Lakers win five NBA championships, took to Twitter on Monday morning, posting a photo of his signature on the contract.
— Kobe Bryant (@kobebryant) November 25, 2013
The Lakers also posted a photo of Bryant signing the deal on their Twitter account.
— Los Angeles Lakers (@Lakers) November 25, 2013
Bryant is the Lakers' all-time leading scorer and ranks fourth on the NBA's career list. He returned to practice this month but isn't sure when he'll be back in uniform.
The Lakers could not have signed Bryant to longer than a two-year extension because of the NBA's over-36 rule, which prohibits teams from extending their own players who are past that age. Teams have the option of extending their players 36 and older for two years in-season or for three years after their age-35 season.
Bryant said last week that he could adjust his game and contribute something to the Lakers now, but he wants to make sure he's ready to play for the long haul before he returns for his 18th season.
Lakers coach Mike D'Antoni has said Bryant will return whenever he says he's ready.
The contract is another milestone in Bryant's remarkable career. He was a 17-year-old high schooler when the Lakers acquired him after the Charlotte Hornets chose him in the first round of the 1996 draft, and Lakers fans watched as he evolved into one of the most dominant scorers in NBA history, dazzling fans with his offensive inventiveness and drawing critics for his ball-dominating style of play.
Bryant won three championships with Shaquille O'Neal from 2000-02 and added two more with Pau Gasol in 2009 and 2010, winning the Finals MVP award after each of those titles. He won scoring titles in 2006 and 2007 and has earned 15 selections to the All-Star Game -- with four MVP awards from the showcase -- and two Olympic gold medals with the U.S. national team.
Bryant hasn't given up hope of adding a sixth championship ring to his trophy case, even while the Lakers struggle to keep up with the league's best teams.
With his immediate future secure, Bryant can focus on getting back to full strength on his injured leg.
"It's always a much greater appreciation for it," Bryant said of his imminent return. "You understand the mortality that comes with being on that doorstep. There's always a sense of enjoyment when you come back."
ESPNLosAngeles.com's Ramona Shelburne, ESPN's Chris Broussard and The Associated Press contributed to this report.