Yeovil opened the scoring in the exciting first half through Reuben Reid, who headed home Edward Upson's left-wing cross in the 16th minute.
The sides continued to exchange shots until the final five minutes of the first half.
Chris Brunt equalised in the 39th minute with a thunderbolt from 30 yards, before Shane Long turned in Brunt's cross on the stroke of half-time to give the Premier League side the lead.
Yeovil were not fazed, however, as Reid nodded in another header on 48 minutes to set up an intriguing second half.
Yassine El Ghanassy buried a 25-yarder to give the visitors a 3-2 lead on 73 minutes before Long wrapped up the result in the 81st minute with an effort from the edge of the box.