It was the striker’s first appearance since suffering a back injury against West Brom on New Year’s Day and he marked it by rising at the far post to beat Frank Fielding from close range after Andy Carroll had done well to get in a cross from the right.
The outcome was harsh on the Sky Bet League One promotion contenders, who were competitive throughout and gave their Barclays Premier League opponents all the trouble they could handle.
City looked the more threatening side for most of a lively first half and it took two goal line clearances to keep the Hammers on level terms.
Mark Noble was on hand to block Matt Smith’s fifth-minute header after Aden Flint’s power in the air at a corner had set up the chance.
And Carroll did even better to divert another Smith header over his own crossbar in the 26th minute, leaving the big City striker holding his head in disbelief after he had connected with a Jay Emmanuel-Thomas cross.
Smith had already seen an early shot blocked by James Tomkins and Joe Bryan fired across goal from an Emmanuel-Thomas pass as the home side displayed the confidence gained from their league form this season.
It took West Ham until the 37th minute to force a save from Fielding. Then Carroll’s close-range shot was straight at the City goalkeeper from a Carl Jenkinson cross.
Kevin Nolan had a shot charged down by Bryan as the first half drew to an end, but it had been a largely frustrating one for the Premier League outfit.
City were more energetic in midfield, with Luke Freeman and debutant loanee George Saville showing up well.
The second half began more quietly, with an Emmanuel-Thomas free-kick from 25 yards bringing a comfortable save from Adrian in the 55th minute.
West Ham were still struggling to put any meaningful moves together and Sam Allardyce had seen enough, sending on Sakho and Morgan Amalfitano for Enner Valencia and the out-of-sorts Alex Song before the hour mark.
Stewart Downing sprang to life in the 62nd minute, driving at the City defence and sending a powerful shot over from the edge of the box.
But it was a rare moment of anxiety for Fielding. At the other end Smith continued to pose problems, heading over from Bryan’s left-wing cross.
Flint was outstanding at the back for City and did well to block a Sakho shot in the 75th minute and seconds later the lively Hammers substitute went closer, grazing the crossbar with the fierce shot from 12 yards.
Home boss Steve Cotterill responded by sending on Scott Wagstaff for Mark Little at right wing-back as the visiting fans did their best to lift their team following Sakho’s efforts.
West Ham were looking increasingly solid, but Nolan picked up a booking for a late challenge on Bryan, whose deep cross from the left was then headed over at the far post by Luke Ayling.
Amalfitano forced a save from Fielding with a curling shot from distance just before the deadlock was finally broken. Even then, City almost forced an injury-time equaliser when Smith headed inches wide from an Emmanuel-Thomas cross.