Danny Haynes returned to haunt former club Bristol City as Barnsley secured only their second win in 11 matches in a dramatic six-goal thriller at Oakwell.
Haynes, who left Ashton Gate in January, scored the hosts' second goal as they fought back from a goal down to post a solid 4-2 win.
Marvin Elliott's strike after just six minutes handed the Robins the advantage but he then conceded the penalty which Andy Gray converted to trigger a stunning comeback for Barnsley.
Haynes put them ahead before Jacob Butterfield scored the goal of the match to put the Tykes in control at the break.
Paul McShane added a fourth before Nicky Maynard grabbed a late consolation from the spot.