The 28-year-old, who has also played for Charlton Athletic, has two Republic of Ireland caps and played all but one of the Blues’ games in the past two seasons.
Randolph has made more than 300 senior appearances and has also played for Motherwell as well as taking in loan spells at Accrington, Gillingham, Bury and Hereford United.
“My initial reaction to joining West Ham is excitement,” said Randolph. “It was a tough decision turning down Birmingham’s offer of a new contract because of the second part of the season we had and the team we had built.
“They are a great group of lads and staff but I felt like I couldn’t turn down the chance of joining a club like West Ham. Everybody wants to try and get to the top of their profession and I’m no different.”