Cole, 31, was allowed to leave Liverpool for free after making only nine Premier League starts for the Merseysiders following a Bosman move in the summer of 2010.
He rejoins his first club, where he won the FA Youth Cup in 1999 and made 150 appearances before leaving Upton Park for Chelsea following their relegation in 2003.
The midfielder will wear the same number 26 shirt that he wore after emerging from the youth ranks in East London.
"It is a great move for me," Cole told the club's website. "Coming back here brings back all the memories of the pitches I learnt how to play on.
"This is where I learnt my trade and I'm happy to have another chance to be here. I've always loved West Ham and I hope I can give the club a few memorable seasons.
"The timing was right for me to come back and I'm happy. I'm back in London and I'm delighted to be here. I want to be here and I want to make an impact," he added.
"The place has not changed much to look at, but I think Sam has done a great job with the team. A few years ago, the club was in a bad way and Sam has done brilliantly.
"All in all, it will always be West Ham and the history will always be here and everywhere I go around the world, people love West Ham. Everywhere I go, people know me for having started here."
After leaving West Ham for Chelsea, Cole won eight major trophies including three Premier League titles, was named in the Professional Footballers Association team of the year in 2006.
But after joining Liverpool as a free agent, he was sent off on his Premier League debut and missed a penalty in his next appearance, a Europa League qualifying match against Trabzonspor. The poor start set the tone for a Reds career hampered by form and fitness problems and he was allowed to spend last season on loan at Lille.
The midfielder, who has won 56 England caps, scored nine goals in 42 appearances for the French club and will have the opportunity to further rebuild his career at the club where he first made his name.
Meanwhile, West Ham have recruited Arsenal striker Marouane Chamakh on loan until the end of the season, manager Sam Allardyce confirmed on Friday.
The Moroccan forward, 28, has struggled to claim a regular place in the Gunners first team after initially impressing following a free transfer from Bordeaux in 2010.
"It looks like we have struck a deal with Arsenal ... for the rest of the season," Allardyce told Sky Sports News.
Chamakh scored twice in the 7-5 win over Reading in the Capital One Cup but his last Premier League came against Blackburn in September 2011.