Tom Owen-Evans bagged a brace for the Bulls who finished the match with nine men after a double dismissal in the second half.
Ben Pollock and Luke Haines both saw red after the break but, despite their two-man advantage, Stamford were unable to reach the fifth round for what have been only the second time in their club history.
They went into the fourth round clash minus the services of a number of first team regulars as they sought a second successive National League North scalp.
Rob Morgan - the match-winner in the victory over Kidderminster - was ruled out through injury along with goalkeeper Dan Haystead and Jon Challinor while skipper Sean Wright was suspended, and recent recruit Cameron Johnson was Trophy-tied.
Former Leicester City goalkeeper Conrad Logan came in for his Daniels debut, with Luke Steele named on the bench, in what was Stamford's first competitive match for more than a month.
They had only received special dispensation from the football authorities to resume training last week and the lack of match action looked to be a telling factor in the opening exchanges.
Hereford - who were missing top scorer Lenell John-Lewis and highly-rated midfielder Giles Coke - had the better of the early stages and forced Stamford into conceding a number of free-kicks in dangerous positions.
Chris Camwell went close with a curling effort, but Stamford managed to repel any set-piece deliveries into their box.
However, they did then find themselves trailing after 10 minutes as a centre from the left picked out Owen-Evans and he was allowed enough time and space to turn and drill home a low shot beyond Logan.
Stamford's team spirit has been a hallmark of their fine form over the past two seasons and they again responded to the early setback.
They rallied to enjoy the lion's share of the first half and created the better opportunities to get back on level terms.
Cosmos Matwasa blazed over a good opening after being picked out by a Tendai Chitiza pass while Connor Bartle stung the palms of Hereford goalkeeper Brandon Hall with a sweet strike.
A succession of Stamford corners failed to create any clear-cut openings before Tom Siddons and Chitiza both saw late efforts in the half blocked.
Hereford brought Logan into action on the stroke of half-time with Camwell unleashed a dipping strike that the Daniels custodian tipped to safety.
The second half then exploded into life shortly after the restart when Stamford midfielder Harry Vince was first cautioned for a late tackle on Pollock.
Pollock decided to extract his revenge in the next attack as he caught Vince late and sent the Stamford man flying which prompted referee Tom Bishop to dismiss the Hereford player.
Stamford looked to take advantage and Vince flashed a cross in which evaded a posse of Daniels attackers.
Bartle curled in another effort which landed onto the top of the Hereford net as new signing Nathan Stainfield was introduced for his Daniels debut to prompt a switch in formation.
This did leave the Daniels prone to the counter-attack and they needed a superb double save from Logan to first deny James McQuilkin and then Owen-Evans' follow up.
The Bulls were then rocked by a second dismissal as Haines was sent off after collecting a second booking, this time for dissent after a foul in the opening period.
The stage seemed set for Stamford to take control of proceedings but, before they could get a stranglehold on the game, they almost immediately found themselves two goals down just a minute after the second dismissal.
A long clearance was misjudged by Stainfield as he attempted to head the ball back to Logan and Owen-Evans took full advantage to race clear and fire home.
It was now a case of all-out attack for Stamford against the nine men with both Jack Duffy and Harry Limb introduced to add to the firepower.
But Hereford are a seasoned higher level side with plenty of experience in their ranks and they saw out any Stamford threats to secure their place in the fifth round where they will entertain league rivals Leamington.
Stamford can now look back on a terrific Trophy run where they claimed the scalps of Stourbridge and Kidderminster and showed they are more than capable of competing with higher level opposition.