The Hammers are obliged to make the deal permanent at the end of the season for a fee that could potentially rise to £30m.
Benrahma joined Brentford from French Ligue 1 side Nice in the summer of 2018 and scored 17 goals in 46 championship games for the Bees last season to take them to the cusp of Premier League promotion, only to lose to Fulham in the play-off final.
The 25-year-old is West Ham’s fourth summer signing after Vladimir Coufal, Tomas Soucek and Craig Dawson.
"I'm very, very happy to be a part of this team," Benrahma told the club's website.
"West Ham is a historic club, which has been in the Premier League for a very long time. It included and still includes good players. It's a massive club in England.
"I spoke to the manager, so I know exactly what he expects from me. I'll try to meet his expectations on the pitch because he's put faith in me and hopefully I can give it back on the pitch.
"I like this prospect [of playing in the Premier League]! I play football to enjoy myself first and foremost, but it's always enjoyable to know you're joining the most-watched league in the world, so I'm definitely looking forward to showing what I can do."
Benrahma, who will wear the number nine jersey at the London Stadium, has been capped five times by the Algeria national team.