After two years without a league penalty, Burnley believed for a minute or so that the FA Cup had brought them a change in fortunes as Matej Vydra stepped up to take a first-half spot-kick against Barnsley.
The whistle blew, however, and the penalty was overturned after VAR spotted an offside on Steven Defour in the build-up to the penalty decision.
It was a huge blow for the Clarets but a lifeline for visiting Barnsley who, as the clock ticked over into 90 minutes, looked to have held out Premier League opposition to secure a replay at Oakwell in just under two weeks' time.
Then Burnley finally got the penalty they thought they'd had earlier in proceedings and Chris Wood converted it in the third minute of stoppage time to secure a heart-breaking winner.
The League One high-flyers had given a good account of themselves in frustrating their hosts, looking as if they were set to end a poor run of form against top-flight opponents in the process. Indeed, since beating Chelsea in the 2008 quarter-final, the Tykes had lost all four FA Cup clashes with Premier League sides by an aggregate score of 2-14.
Daniel Stendel's side dominated possession at Turf Moor, though, playing with the confidence of a team performing well in the league but struggling to create clear opportunities against Sean Dyche's stout defensive line.
In the end there were just three shots on target in the entire encounter, both for the hosts, as the game suffered from wayward finishing and a lack of quality in the final ball.
The fallout was destined to be all about the overturned penalty from the first half until Vydra, the man denied his penalty earlier, was tripped in stoppage time.
Wood swept the ball into the bottom corner to secure progression for the Clarets and leave controversy on the sidelines.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies