Gomez had been linked with a move away from Anfield after making only 21 appearances last season.
The 25-year-old has fallen behind Virgil van Dijk, Joel Matip and Ibrahima Konate in Jurgen Klopp’s list of preferred centre-backs.
Gomez has also endured serious knee and ankle injuries since joining the Reds in 2015.
But Klopp remains confident Gomez still has a big part to play after extending his spell on Merseyside.
“One of the many wonderful things about Joe is he has experience and youth, that’s not a bad combination,” Klopp said.
“He has not long turned 25 but he was at the club before I was. The best thing of all is that his best years are still to come, and I could not be happier that this will happen with us.”
Gomez, who was signed from Charlton, has helped Liverpool win the Champions League, Premier League, FA Cup, League Cup and FIFA Club World Cup.
Gomez added: “It is an unbelievable place to be.In my eyes, probably one of the best – if not the best – clubs in the world at the minute.
“The opportunity to extend my stay here was an easy decision to make, really.
“Obviously, I have been here quite a while now, but in the grand scheme of things I still feel young and the best years are ahead of me. I have got more to learn and the time to do that.”