Niclas Eliasson struck an 87th minute winner as Bristol City maintained their push for a Championship play-off spot with a 1-0 victory over Barnsley at Ashton Gate.
The winger picked his spot at the far post with a low drive after a brilliant run and cross from the left by Jay Dasilva had created the chance.
It was rough justice on Barnsley, who had created plenty of openings themselves in a match of exciting approach play and wretched finishing.
Barnsley were forced into a late team change when Clarke Oduor was injured in the warm-up and Ben Williams was called into the starting line-up.
A wide open first half brought plenty of opportunities for both teams. City were denied by the woodwork after 10 minutes when Josh Brownhill challenged for an Eliasson corner and the ball struck the crossbar off the head of a Barnsley defender.
Conor Chaplin was a lively raider for Barnsley and had two shots blocked after 13 minutes, Ashley Williams making the second vital challenge.
City goalkeeper Dan Bentley reacted well to keep out a 14th minute shot from Alex Mowatt. At the other end, Famara Diedhiou had a low shot deflected just past the far post.
Chaplin's shot following a Mowatt corner was kept out by the combined efforts of Bentley and Andreas Weimann as Barnsley continued to attack with menace.
Diedhiou headed wide at the far post from Eliasson's 27th minute cross before City hit the crossbar again through Williams' near-post header, with Barnsley keeper Brad Collins getting a touch.
Eliasson saw a shot blocked from a Diedhiou pass before the visitors had the final effort of an entertaining 45 minutes, Marcel Ritzmaier firing narrowly wide.
The second half began where the first had left off and Williams had to be alert to block a close-range shot from Chaplin.
Barnsley were looking more likely to break the deadlock and Luke Thomas was left with his hands on his head when failing to hit the target from six yards after 57 minutes.
Eliasson was equally red-faced two minutes later when shooting over from 12 yards after an effort from Weimann had been blocked.
It was Barnsley's turn to hit the crossbar after 62 minutes from a measured chip by Ritzmaier inside the box.
At times it seemed neither side wanted to score as Diedhiou blazed over from a Weimann cross when the City striker should at least have hit the target.
Mowatt fired just wide for Barnsley with neither defence looking comfortable but his team were made to pay for the lack of a finishing touch when Eliasson broke their hearts.