Substitute Chris Wood's stoppage-time penalty sent Burnley through to the fourth round of the FA Cup as they beat Barnsley 1-0 at Turf Moor.
Wood converted from 12 yards after Matej Vydra was brought down in the area by Liam Lindsay.
It was the second time in the match the Premier League hosts had been awarded a spot-kick by referee Simon Hooper, with the first coming in the first half following a foul by Dimitri Cavare on Vydra.
However, that decision was overturned, Hooper halting Vydra as he was running up to take the penalty and signalling VAR was being used, before indicating it was no spot-kick due to offside – an incident that left Burnley boss Sean Dyche looking distinctly unimpressed.
The dramatic finale was harsh on League One Barnsley, who had a Cameron McGeehan goal ruled out for offside just before half-time.
This was Burnley's first home tie in the FA Cup since they were famously beaten by then National League side Lincoln in the fifth round of the 2016-17 competition.
Dyche, whose men were knocked out of the Carabao Cup this season by Barnsley's third-tier rivals Burton, made eight changes to his starting XI from the 2-1 win at Huddersfield that had taken them out of the Premier League relegation zone.
England goalkeeper Nick Pope was among those coming in as he made his first appearance since dislocating his shoulder in July, with Tom Heaton dropping out of the matchday squad and Joe Hart on the bench for a third successive game.
Barnsley's team showed just two changes from their 0-0 draw at Luton on New Year's Day, one being enforced by the sale of Brad Potts to Preston on Thursday.
Aside from a tame Sam Vokes header caught by Adam Davies and a deflected Mamadou Thiam shot that went wide, little of note occurred until the 20th minute when Vydra was bundled over in the Barnsley area by Cavare and Hooper pointed to the spot.
Vydra subsequently prepared to take the penalty and, in a somewhat farcical scene, was then stopped by Hooper just as he started his run-up.
Hooper made the symbol for VAR with his hands and then indicated it was no penalty due to offside, with Dyche looking far from happy in the technical area.
After Vokes had a shot blocked, Thiam and Cauley Woodrow each struck wide of Pope's goal and Barnsley then put the ball in the net via McGeehan's header, but the assistant referee's flag was raised for offside.
Burnley responded with Dwight McNeil hitting an effort wide and a Kevin Long header that was tipped over the bar by Davies.
The hosts created further chances early in the second half as McNeil and Vokes nodded off target, and Vydra missed with a bouncing shot and a header, while Thiam sent a free-kick too high at the other end.
Barnsley's Alex Mowatt went close with a late free-kick before Lindsay fouled Vydra and Wood stepped up and settled the contest.