The narrow victory at Somerset's headquarters saw South Africa level the three-match series at 1-1 as bounced back from a nine-wicket defeat by England at Southampton two days earlier to set-up a winner-takes-all clash in Cardiff on Sunday.
England were on course for an unbeatable 2-0 lead while Roy (67) and Jonny Bairstow (47) shared a second-wicket stand of 110.
But when Roy was given out obstructing the field — the first time this had happened in a T20I — the innings fell away.
De Villiers vows fightback after England defeat
England's cause was not helped by batting second under increasingly dark skies in a match that started at 1600 GMT despite a lack of floodlights on the ground, although home skipper Eoin Morgan did field first after winning the toss.
A target of 12 off the last over became four off the last ball after Liam Dawson hit Andile Phehlukwayo for a boundary.
But he could not repeat the trick and South Africa had a morale-boosting victory to follow their first-round exit at the 50-over Champions Trophy, with this win achieved despite the absence of coach Russell Domingo, who had flown home after his mother was involved in a traffic accident.
Durban-born Roy, dropped from England's Champions Trophy semi-final loss to Pakistan after a run of low scores, was in superb form.
Bairstow fell first, chipping man-of-the-match Chris Morris (2-18) to mid-on.
And then came the turning point.
Roy veered dramatically off a straight course, with the result he placed himself between the incoming throw from Phehlukwayo, which hit him on the heel, and the stumps.
Jason Roy got an embarrassing record to his name when he became the 1st man to be given out obstructing the field in T20Is. #ENGvSA #SAvENG pic.twitter.com/AcdZjCPjjZ
— Chinmay Jawalekar (@CricfreakTweets) June 24, 2017
South Africa appealed and, after on-field umpires Rob Bailey and Michael Gough referred the decision, Roy was given out by TV umpire Tim Robinson.
Roy was clearly aghast but Morgan insisted it had been a "50-50 call". "Everyone in the changing room thought it could go either way, so it's not massively controversial," Morgan told reporters. "You can see why the umpires gave him out."
But England all-rounder Ben Stokes, who was given out obstructing the field in a one-day international against Australia at Lord's two years ago when he reacted to a shy at the stumps from bowler, Mitchell Starc by sticking out a glove, was unimpressed.
"Can't believe that @JasonRoy20 was given out in that manner today," Stokes, rested from this match, tweeted before continuing "embarrassment is the only word that can be associated with the decision”.
South Africa captain AB de Villiers defended the decision. "We were in the right to ask the question of the umpires,” he said. "It's not an easy decision and it's never nice to get out like that."
England still had batting to come after Roy's exit. England, who had been 133-2 at the start of the 16th over, lost four wickets for 34 runs before finishing on 171-6.
Earlier, South Africa's total of 174-8, de Villiers' top-scoring with 46, was a significant improvement on Wednesday's 142-3.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ