Petric was released from Fulham at the end of last season after scoring 5 goals in 10 starts and has been without a club all summer.
In light of the setback to Andy Carroll, the 32-year-old will provide back and support to the only fit, recognised striker on the books at the moment – Modibo Maiga.
Speaking to the official site, Petric said “I’m very happy, excited and looking forward to training with the team and to the first game. “I know the Premier League and I’m happy to be back in the Premier League, because it’s a fantastic league and I’m really looking forward to being part of this team and this Club.
“There are a lot of good players here and I’m happy to be part of such a good team and I hope we can all celebrate my first goal for West Ham as soon as possible.
“I didn’t speak to Sam until today but I’ve heard a lot about him and I spoke to Guy Demel, who I know from my time at Hamburg and I’m sure I’ll have a good time here.
“I remember playing at West Ham last year and it was a very tough game for us at Fulham. I think we lost 3-0! It’s not easy to come here and take points away.”