Liverpool didn't announce the fee paid for the Switzerland international but British media reported they activated a 13.5 million pounds (18 million dollars) release clause in his contract.
“It’s a huge club with big history, big players and a fantastic coach,” Shaqiri told the club's website.
“As a player you always want to be on the biggest stage in football.
“I want to be with the best and I want to win titles. That’s what I’m here for.”
Shaqiri joined Stoke from Inter Milan in 2015 and led the Potters with eight goals last season as they were relegated from the Premier League.
The 26-year-old has scored 21 time in 74 appearances for Switzerland and started all four games as they reached the last-16 at the World Cup in Russia this summer.
“From our perspective, he is someone who makes a big difference to the squad and team, because he can fit in so many positions in our system,” Liverpool manager Juergen Klopp said.
“He gives us greater flexibility in how we can use our current players also. This is cool.”
Shaqiri began his career with Swiss club Basel before moving to Bayern Munich, where he won two Bundesliga titles and the Champions League in 2013.