The Senegal forward scored 20 goals last season to help his side secure promotion to Ligue 1 and he became a target for the Hammers when they lost Andy Carroll to the latest in a series of long-term injuries.
Sakho's move to the Premier League seemed in doubt earlier in the week when Metz claimed West Ham had tried to change the terms of the deal and bring him to Upton Park on a season-long loan.
But fresh talks on Thursday brought an end to the saga and the 24-year-old was presented as a Hammers player.
He spent a number of seasons playing mainly off the bench for Metz, and had a loan spell with Boulogne, but he made his breakthrough in the 2012-13 season in the third tier, scoring 19 goals, and he continued that progress last season.
"This is a proud day to have signed for West Ham, I really love English football and I've dreamed of coming to play for one of the big English clubs. Today, West Ham have given me that opportunity and I didn't hesitate to grab it," Sakho told West Ham's official website.
"I'm looking forward to playing. It's more than a month now that I've been training for this and right now I think I'd be ready to pull on the club colours.
"I've come here to continue as I was at Metz. I'm going to give it my all, going flat out on the pitch and I think the fans will appreciate that."