Alex Jakubiak and Tom Lockyer were both on target as Rovers began their Checkatrade Trophy campaign on a positive note.
Jakubiak grabbed his first goal for Rovers on the hour mark, with a composed finish to put Rovers ahead.
It was a late goal from Tom Lockyer that sealed the win, as the defender touched home a corner from Sam Matthews in a night that welcomed many postives for Rovers.
Rovers welcomed Stuart Sinclair into the starting eleven for the contest, as Manager Darrell Clarke named a host of Development Squad players on the bench for the encounter.
The game had a lively tempo from the outset, with Rovers almost opening the scoring inside the opening two minutes, as Stefan Payne saw his goalbound volley deflected behind for a corner.
Both Sam Matthews and Alex Jakubiak had attempts on goal held by Anang in the opening minutes, as Xande Silva came close at the other end, shifting his side-footed attempt narrowly wide of the Rovers goal.
Xande Silva again had a view of the Rovers goal shortly after, on this occasion, his effort was thwarted by a crucial block from Tom Lockyer, who managed to sense the danger and block Silva's goalbound volley.
Rovers had chances of their own, as Sam Matthews shaped an inswinging corner that causes problems at the back for West Ham. Stefan Payne managed to glance a header back to towards goal, but the attempt was rushed clear by Joe Powell inside the congested penalty box.
As the first half edged closer to the interval, Rovers crept more chances on goal. Tom Lockyer headed over after he lost his man inside the area and was able to meet an Ed Upson free-kick.
With minutes remaining in the first half, Upson tried his luck from range, as his driven attempt wasn't held cleanly by the Joseph Anang, who recovered to make a save to deny Stefan Payne from tapping home the rebound.
At the break, Joe Partington was introduced, replacing Daniel Leadbitter, as the right-back marked his return from a lengthy spell on the sidelines.
Partington was involved instantly, launching a teasing cross that almost found its way to Alex Jakubiak.
The deadlock was broken on the hour mark, as Ed Upson guided a pass into the feet Jakubiak, who slotted home a neatly placed side-footed finish to put Rovers ahead, in what was his first Rovers goal.
In the aftermath of the goal, Stuart Sinclair was replaced by Luke Russe in what was Rovers' second change of the evening.
Chasing a way back into the contest, West Ham pushed for an equalising goal. Jack Bonham had to be alert to make a smart save from Sean Adarkwa, as the Rovers 'keeper was able to tip a close-range shot onto the post.
The victory was cemented inside the final ten minutes, as Tom Lockyer bundled the ball home from a Sam Matthews corner to stretch the advantage for Darrell Clarke's side to a two-goal cushion - with little drama at the other end in the closing minutes.
Next up for Rovers is the visit of Coventry City to the Mem this Saturday.
Rovers: Jack Bonham, Michael Kelly, Tom Lockyer (C), Tom Broadbent, Daniel Leadbitter (45' Joe Partington), Ed Upson, Ollie Clarke, Sam Matthews (88' Mo Baghdadi), Stuart Sinclair (58' Luke Russe), Alex Jakubiak, Stefan Payne.
Subs: Adam Smith, Alfie Kilgour, Joe Partington, Rollin Menayese, Luke Russe, Mo Baghdadi, Cameron Ebbutt
West Ham United: Joesph Anang, Xande Silva, Reece Oxford (C), Grady Diangana, Joe Powell, Olatunji Akinola, Ben Johnson, Conor Coventry, Alfie Lewis (73' Vernon Parkes), Ajibola Alese, Bernardo Rosa.
Subs: Daniel Jinadu, Mason Barrett, Emmanuel Longelo, Sean Adarkwa, Vernon Parkes, Peter Stroud, Sebastian Nebyla.