The 25-year-old, who has been out injured with a stress fracture in his back, was entering the final few months of his existing contract. Several counties, including Warwickshire, were rumoured to be circling but Mahmood now be at Old Trafford until at least the end of the 2024 season.
Mahmood, who has featured in two Tests, seven one-day internationals and 12 Twenty20s, said: "I am really pleased to be able to commit my future to the club who have shown faith in me from my days in age-group cricket to now at first-team level.
"It's been a difficult few months since suffering the stress fracture to my back, but the support from Lancashire Cricket and in particular our medical department has played a huge role in my ongoing recovery.
"I am now looking forward to getting back to full fitness as soon as possible and helping the Red Rose to fulfil our ambitions over the next couple of years and beyond."
Mahmood has taken 71 first-class wickets at an average of 26 while in the Vitality Blast he has claimed 28 dismissals at 20 with a strike-rate of 15.
Mark Chilton, Lancashire's director of cricket performance, added: "Saqib is an immensely talented fast bowler and we are thrilled he has committed his future to the club.
"It's obviously been an incredibly frustrating season for him personally with the injury but he's making good progress and we're looking forward to getting him fit and firing for us again."