It looked to be a one-sided affair when the league leaders raced into a three-goal lead through Jordi Alba, Cristian Tello and Messi after just 18 minutes.
However, Depor replied with a Luis Pizzi penalty and an Alex Bergantinos goal before Messi struck again to put Barca back in the driving seat.
Pizzi's second of the match then set the nerves jangling once more and the dismissal of Javier Mascherano gave the visitors further food for thought until Messi made it 5-3 with his treble.
The excitement did not stop there though, and an own goal from Alba brought Depor back within touching distance of their opponents with 11 minutes remaining.
However, despite their best attempts to grab a deserved equaliser, their luck ran out as Barca held on for the points.