Benrahma, prised from the Bees for £30million three years ago, climbed off the bench to provide the only moment of quality in a dour third-round encounter.
The Algerian winger fired home from 25 yards before opting not to celebrate against the side he spent two and a half years with.
For West Ham at least there was a measure of revenge for the 2-0 Premier League defeat inflicted by Brentford eight days earlier.
But it was a tough watch. In a torturous first half played in teeming rain, neither side showed any real inclination to attack.
The best chance fell to Brentford when Keane Lewis-Potter crossed from the right and Yoane Wissa, who scored twice in Monday’s 3-1 win over Liverpool, was denied at close range by Lukasz Fabianski.
The Bees were still without Ivan Toney, who left the field on a stretcher at the London Stadium last week, and they missed his presence up front
But they had another opportunity when Mads Roerslev robbed Emerson Palmieri on the touchline and played in Keane-Potter, who blazed over the crossbar.
Brentford goalkeeper Thomas Strakosha was making only his second appearance of the season but West Ham failed to test him once.
Lucas Paqueta tried his luck from a tight angle and lifted his effort too high while Jarrod Bowen dragged a shot wide.
Lewis-Potter, a bit-part player this season and one of seven changes for the Bees, at least looked eager to impress.
At the start of the second half the former Hull winger raided down the left and cut inside but his drive was held by Fabianski.
West Ham should have scored moments later when Emerson drove to the byline and sent in a low cross but Tomas Soucek prodded wide six yards out when Bowen looked better positioned to score.
Emerson then swung in a deep free-kick which Craig Dawson met at the far post with a half-volley which spun wide.
The Bees’ new signing Kevin Schade, who has joined on loan from Freiburg with a view to a permanent switch, was summoned from the bench for his debut 20 with minutes to go.
A lightning-quick winger, Schade immediately sped around Dawson forcing the defender into a challenge which earned him a booking.
But it was Hammers substitute Benrahma who won it for the visitors with 11 minutes remaining.
Declan Rice’s firm challenge on Wissa in midfield left the striker in a heap and Benrahma raced forwards before launching a rocket into Strakosha’s net to send West Ham through.