The German-born Cameroon international has played 181 league games and scored 17 goals for the club he joined as a nine-year-old.
"I have always said that I would only bid goodbye to Schalke to experience something fundamentally new," the 24-year-old told Schalke's website. "That's why I never considered a switch within the (German) league.
"Even though the decision was definitely not easy, I am convinced that now is the time to make the next step."
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
Liverpool failed in their attempts to sign Matip during the January transfer window but the defender will now get a chance to work under former Borussia Dortmund coach Juergen Klopp when he moves to Anfield on July 1.
(Reporting by Pritha Sarkar, editing by Ed Osmond)
