Lamb, 26, came through at Edgbaston having joined the club at Under-9s, making his first team debut in 2016. He was a member of the side that won the 2021 County Championship, playing 13 games and contributing 565 runs.
A versatile middle-order batter who can also bowl medium pace, Lamb averages 31.23 in first-class cricket and 42.24 in List A.
Derbyshire's head of cricket, Mickey Arthur, said they had targeted Lamb to strengthen the squad after finishing fifth in Division Two in his first season in charge.
"Matt had a strong season in Division One and that's the calibre of player we want to bring to our club," Arthur said. "Signing a player with a good amount of top level experience is an example of our intent. Our batting has been strong this year, but Matt's arrival increases that competition for places and re-enforces our batting depth in all formats."
Lamb finished the season out of the Championship side at Edgbaston, but was second in the club's averages, scoring 487 run at 48.70 with two hundreds in eight appearances.
"I leave Edgbaston with a heavy heart, but I'm incredibly excited for the next chapter of my career," Lamb said. "I will be forever grateful and thankful to everybody at the Bears who helped and coached me from an eight-year-old cricket lover to a County Champion.
"I have made friends for life at the club and will always look forward to returning with Derbyshire.
"Mickey Arthur's project at Derbyshire really excites me, there's a talented group of players and the level of ambition is high, that's something I want to be a part of. I've been pleased with my performances over the last couple of years, but I want to push myself across all formats, this is the opportunity to do that and I'm looking forward to getting going this winter."