The former Manchester United striker has penned a three-year contract, which is reportedly worth £140,000 a week, making him the highest-paid player in the club's history.
Hernandez had a successful spell at Old Trafford, scoring 59 goals and winning two Premier League titles, but his time at the club ended in 2015 when he joined Leverkusen after a loan spell at Real Madrid.
During his two-year stint in Germany, the striker, nicknamed Chicharito, scored 39 goals in 76 games.
After joining the Hammers, Hernandez told the club's official website: "I am very happy to join West Ham United. For me, the Premier League is the best league in the world and when the opportunity came, I was desperate to sign for this club.
"It was not a difficult decision. West Ham is a historic club, and very ambitious – this summer you can see with the players signed that they are looking to have a very good season.
"I've had three fantastic years playing in Spain and Germany, but England was really the first big chapter in my career and I am so happy to be back. I am desperate for the season to start and to help the team achieve all their objectives."
Hernandez could make his first Premier League appearance for West Ham against his former club United on August 13.