The 25-year-old, who will cost an initial £25m with a further £5m coming in add-ons, was wanted by Crystal Palace earlier in the window, but a potential deal failed to progress over the player’s wage demands.
Aston Villa were tentatively interested as well, having signed Benrahma’s former teammate Ollie Watkins from the Bees.
The Hammers were also keen on Bournemouth’s Josh King, but have settled on Benrahma after striking a deal with the Championship side.
Failure to win promotion to the Premier League after defeat in the play-off final last season to rivals Fulham appeared to point to an exit this summer for the player.
But progress over a deal has been slow until this point, with the player starting the Championship season with Brentford, but David Moyes has finally landed the talented winger.
Benrahma, who joined Brentford from Nice two years ago for £1.5m, shone for the Bees in the Carabao Cup last month.
He inspired a 3-0 victory over Fulham with two goals, including a sublime individual effort.