The 30-year-old striker initially left the club earlier this summer, and had held talks with a number of other teams.
However, as no move materialised, Cole returned to train with the Hammers last month with a view to signing a deal - if he could prove his fitness.
Now the former England international has returned to the club on a three-month deal, with a view to extending it in January.
Cole told West Ham TV: "I'm in an excellent mood, am happy to be back and can't wait to get working with the lads again and start my season off.
"I've been working hard with the strength and conditioning coach Mathew Monte-Colombo in the gym and he's been really hands-on with me to get me up to standard to train with the team and get my match fitness up as quickly as possible with a view to signing.
"I feel fit and raring to go and it's time to start knocking on the manager's (Sam Allardyce) door to get some games under my belt."
Reflecting on his departure over the summer, Cole added: "At the end of the day, everything happens for a reason and you don't always choose what is going to happen to you.
"We decided to part ways in the summer but West Ham and me have ended up together again. Hopefully I can come in and be who I am and help the team achieve what we need to achieve."
Cole will now be eligible to play against Manchester City at Upton Park this Saturday evening - a game you can see live on Sky Sports.
Cole first joined West Ham back in 2006 and has played nearly 250 games for the club.