The 30-year-old Egypt forward only had a year left on his previous deal and there had been doubts about whether he would stay.
Mohamed Salah has scored 156 goals in 254 appearances during his five years at Anfield since moving from Roma.
He said, “I feel great and I am excited to win trophies with the club. It’s a happy day for everyone. We are in a good position to fight for everything.”
Salah has won the Champions League, Premier League, FA Cup, League Cup, Fifa Club World Cup and Uefa Super Cup during his time at Anfield.
He has also won or shared three Premier League Golden Boots and been named the PFA player of the year twice while with Jurgen Klopp’s side.
The renewal comes as a big boost after the departure of fellow forward Sadio Mane to Bayern Munich this summer.
Liverpool won the FA Cup and Carabao Cup this season but were in the running for a quadruple until the final week of the season, falling just short in the Premier League and losing the Champions League final to Real Madrid.
They have recruited Benfica and Uruguay striker Darwin Nunez for an initial £64m to offset the loss of Mane.
“It takes a little bit of time, I think, to renew, but now everything is done so we just need to focus on what’s next,” said Salah.
“I think you can see in the last five or six years the team was always going [upwards]. Last season we were close to winning four, but unfortunately in the last week of the season we lost two trophies.
“We have new signings as well. We just need to keep working hard, have a good vision, be positive and go for everything again.”
Last season, the forward again hit the 31-goal mark to help Liverpool to a domestic cup double as well as going close in the Premier League and Champions League once more, narrowly losing out in both. He again collected both the FWA and PFA prizes for the year’s outstanding player in recognition of his form – and added the Premier League Playmaker prize for most assists to his latest Golden Boot.