Philippe Coutinho had the visitors ahead inside of two minutes, smashing a half-volley into an empty net after Hugo Lloris was caught out trying to chase down a Messi through ball.
Barcelona were two up before the half-hour mark thanks to a sensational goal from Ivan Rakitic, who side-volleyed home an unstoppable shot after Coutinho had played the ball back to him at the top of the penalty area.
Messi nearly put the game away twice at the start of the second half, but both times his low curling shots clattered off the left post to keep Spurs trailing by just two goals.
And minutes later, Tottenham would find their first when Harry Kane picked up an Erik Lamela pass, charged into the area and cut back to his right foot before powering a shot past Marc-Andre ter Stegen to make it 2-1.
Tottenham's celebrations would be short-lived, though, as Barca hit back right away with Messi finding the inside of the post he'd hit twice to open the half from a Jordi Alba cutback that Luis Suarez allowed to run through to his Argentine teammate.
Kane's hard work on the right flank led to Spurs second as he won the ball back from Barcelona and teed up Lamela, whose shot took deflected off Clement Lenglet and over the outstretched arms of a diving Ter Stegen to again cut the deficit to one goal.
Spurs pushed hard for the equaliser and nearly had it in the 84th minute when Lucas Moura broke free in the Barcelona area only to see his shot from 8 yards out deflect off Lenglet and out of touch.
Messi put matters to rest just before full-time after a bad giveaway from the Tottenham defence left the Barca talisman alone with only Lloris to beat and he made no mistake, tucking the ball into the bottom right corner to seal the points.
Barcelona have six points to top the group as they lead Inter Milan on goal differential, while Tottenham have it all to do if they are to reach the last 16 having lost their opening two matches.