The Robins, who were held to a 1-1 draw in the original second-round game, took the lead when Shaun Harrad converted from the penalty spot in first-half stoppage time.
Sam Clucas levelled for the Blue Square Bet Premier Bulls in the 74th minute but Mohamed booked Cheltenham a lucrative clash against David Moyes' men.
Hereford suffered a damaging blow as early as the 11th minute when leading scorer Ryan Bowman was forced off with a knee knjury.
Otherwise the first-half produced little of note until stoppage time.
Cheltenham keeper Scott Brown made a blinding save to deny Clucas a goal, with the action immediately returning to the other end where Cheltenham took the lead.
Jermaine McGlashan hit the deck under a challenge from Andy Gallinagh and referee Dean Whitestone awarded a soft penalty before Harrad rammed the spot-kick past James Bittner.
Hereford huffed and puffed in the second period but Cheltenham seemed comfortable until the fortuitous equaliser arrived.
Clucas sent in a cross from the left but there appeared to be little danger as the ball dribbled through the area before landing in the corner of the net.
There were few chances as the game progressed through added time before Mohamed struck with seven minutes remaining in extra-time.
Daniel Bentley was Southend hero as they beat Bury 3-2 in a penalty shoot-out following their 1-1 FA Cup second-round replay draw at Roots Hall.
Gavin Tomlin cancelled out Zac Thompson's opener for the Shakers to ensure the game went to spot kicks.
And that enabled Bentley to centre stage as he kept out penalties from David Worrall and Mark Hughes to send Blues through to the third round.
Up until then, both sides struggled to deal with a difficult pitch in freezing conditions.
However, with 59 minutes on the clock, the Shakers went in front, following a rare mistake from Ryan Cresswell.
The towering Shrimpers centre-back gave the ball away poorly in his own penalty area and that enabled Andy Bishop to tee up Thompson and he made no mistake with an assured finish from 12 yards.
But Bury were in front for just four minutes as Tomlin headed Blues back level.
The in-form forward was picked out by an excellent right wing cross from Sean Clohessy at the near post and nodded the ball in to the bottom left hand corner of the net.
- Sports & Recreation
- Shaun Harrad