South Africa 174 for 8 (de Villiers 46, Curran 3-33) beat England 171 for 6 (Roy 67, Morris 2-18) by three runs
Scorecard and ball-by-ball details
The dismissal of Jason Roy, given out for obstructing the field, changed the course of a game that England appeared to have won and saw South Africa level the T20 series at 1-1 with one to play.
Roy, with his first 50 in 11 international innings, appeared to have put England on course for a series-clinching victory as he added 110 in 70 balls with Jonny Bairstow for England's second wicket. But when Bairstow lofted to mid-on and Roy was given out a few deliveries later, South Africa's seamers - enjoying a track offering pace and bounce - turned the screw in expert fashion amid failing light and mounting excitement.
The result was uncertain until the final delivery after Liam Dawson hit the penultimate ball for four. Had it travelled another six inches, it would have left England requiring just two to win from the final ball. As it was, Dawson was required to hit another four (or three to ensure a Super Over) and was unable to make contact with his heave.
While the decision to give Roy out - made after consultation with the TV umpire - was booed by a partisan, passionate crowd, it wasn't especially controversial. Having been sent back by Livingstone, Roy turned to regain his ground and, in doing so, ran across the pitch so he was in between the fielder - Andile Phehlukwayo, at point - and the stumps. The throw subsequently hit Roy on the boot. The TV umpire, Tim Robinson, could have made no other decision. It was, however, the first such dismissal in international T20 cricket.
"It was probably a 50-50 call. You could see both sides of it," England's captain, Eoin Morgan, said. "Everyone in the changing room thought it could go either way so it's not massively controversial. You can see why the umpires gave him out. Jason obviously looked at the fielder but after that he ran in a straight line so that's why it was a 50-50 call. They were certainly entitled to appeal and the spirit of the game is open to interpretation.
'We were going really well for much of the chase but we lost a wicket at a crucial moment and nobody was able to take it up after that. We didn't deserve to win because we didn't capitalise on the start we had."
It was not, perhaps, the result the sell-out crowd wanted. But it was the sort of dramatic finish the occasion - the return of men's international cricket to Taunton for the first time since the 1999 World Cup - warranted. Cheered on by 12,420, (the Somerset chairman reckoned the club could have sold out this game, only England men's second international here and their first since the 1983 World Cup, four times over) the only thing an excellent venue lacked was floodlights. They are to be installed in the coming months, but they would have been very handy towards the end of this match.
It seemed a mightily unlikely result as Roy and Bairstow took control. While Roy was not, at first, at his most fluent, such was his conviction, that the runs flowed. He took four fours off Morne Morkel's second over - two of them edges that could have gone anywhere - gradually settled and registered his second T20I half-century with a straight-driven six into the Ian Botham stand off the left-arm wristspin of Tabraiz Shamsi.
Bairstow lost little by comparison. He has waited a long time for his opportunity in England's limited-overs teams and the evidence of the last couple of weeks suggests he is determined to take it.
Having equalled his career-best T20I score in the first match of this series, he made another 47 here and produced a couple of shots - a cover-driven four off something approaching a yorker from Morkel and a pull for six off the same bowler - that were especially memorable.
But when he chipped a full, inswinging delivery from the excellent Chris Morris to mid-on, it initiated a collapse that saw England lose five wickets for 42 runs in the next six overs. It was Morris, bowling with sharp pace, who most unsettled the England batsman with Liam Livingstone, one of two debutants, finding the step up in class tough to negotiate (he hit one boundary in 18 balls and was run out from the fourth ball of the final over). On 7, he also survived a caught behind appeal from Morris' final delivery - an attempted pull that saw the ball flick the bat and his shoulder - that replays suggested should have been given out.
Phehlukwayo, who bowled a nerveless final over from which 12 were required, claimed the key wicket of Jos Buttler - the returning hero undone by a fine yorker - while Morgan thumped a full toss to mid-on from the skiddy pace of Dane Paterson.
Earlier Tom Curran took three wickets on debut as South Africa were restricted to what appeared to be an under-par 174 for 8. After claiming a wicket with his second ball in international cricket - Reeza Hendricks bottom-edging an attempted pull on to his stumps - Curran returned to bowl the last couple of overs from the Somerset Pavilion End and impressed with his control and variations. He claimed two more wickets in that spell, with Morris mishitting a slower-ball to long-on and Phehlukwayo bowled first delivery by a searing yorker. Generating surprising pace - as high as 88mph - he did more than enough to suggest he had a future at this level.
Liam Plunkett was the quickest of the seamers, though. Hitting 90 mph at times, he claimed two wickets with his slower ball - Mangaliso Mosehle gloving a pull and David Miller edging an attempted force - while Farhaan Berhardien's promising innings was ended by a Chris Jordan yorker.
It wasn't a flawless performance in the field from England, though. Jordan, normally so reliable, dropped Berhardien on 11 at mid-off - the ferocity of the drive forcing the ball through his hands and on to his jaw - while Livingstone on the deep midwicket boundary dropped a more straightforward chance offered by Morris on 11. England also conceded five wides, four of them by Jordan, who also - most uncharacteristically - allowed a ball to elude his grasp at mid-off and scurry away for four. They were to prove costly mistakes.
South Africa were grateful to a far more convincing batting performance from AB de Villiers, in particular, and JJ Smuts. Relishing the extra pace of the surface, de Villiers rushed to 46 in 20 deliveries with a swept six off Dawson and a driven one off Plunkett the highlights, before he appeared to lose his grip on the bat as he attempted to drive David Willey and instead skied a catch to mid-off.
Smuts, hitting the ball unusually hard, also made an accomplished 45 but the final total of 174 seemed to be around 25 under par on a fine batting surface. South Africa's pace and England's errors, however, meant the sides meet in Cardiff on Sunday with the series all to play for.