The 30-year-old confirmed the news on his Twitter account saying: "I'm a West Ham United player again. Thanks for the support."
The 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.
"I'm in an excellent mood," the striker told West Ham's official site.
"I'm 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 door to get some games under my belt."
The former England international has agreed an initial three-month deal, with a view to extending it in January.
Cole will now be eligible to play against Manchester City at Upton Park this Saturday evening.
Cole first joined West Ham back in 2006 and has played nearly 250 games for the club.