Marc McNulty grabbed a double and Florian Kamberi and Stevie Mallan were also on target for Paul Heckingbottom's side, who climb above Motherwell and St Johnstone.
In a highly entertaining match, Paul McGowan and Martin Woods scored for Jim McIntyre's men, who remain in 10th place in the table.