The 32-year-old England international was released by the relegated Hammers after his contract expired at the end of last season.
He follows former international defender Jonathan Woodgate to the club after the ex-Tottenham centre-back agreed a deal last month having been released by the Londoners.
"This is another fantastic deal for this football club when you consider the quality and experience of the lad," manager Tony Pulis told the club's website.
Pulis continued: "We now have strength in depth in our defence with both Matthew and Jonathan on board and we've managed to achieve that without significant outlay on transfer fees, which is quite remarkable in today's market of vastly-inflated prices.
"Their experience of performing at the highest level will be a valuable asset to us because we have some good young defenders and a young goalkeeper.
"Matthew was anxious to stay in the Premier League following his departure from West Ham and he sees this as the perfect opportunity for him to further his ambitions at both club and international levels in the future."
Upson will not only face competition from Woodgate for a place in the back four but also the established central defensive pairing of captain Ryan Shawcross and Robert Huth.
However, he is looking forward to the challenge.
"There is a lot of competition for places here and that is part of the attraction," he said.
"I will relish the fight for a spot because it draws the best out of players.
"The manager has talked to me about the culture here, the discipline and the organisation, and that is an environment I am looking forward to working in."
Upson has been signed in time to be registered for Stoke's forthcoming Europa League play-off against Swiss side FC Thun.
He will train with his new team-mates for the first time on Wednesday and is likely to go into the squad for Sunday's visit of Chelsea in Stoke's Premier League opener.