Diego Godin had seemingly salvaged Atletico a draw 20 minutes from the end, but Messi broke the hosts' hearts with a late goal to make Diego Simeone's men rue their missed opportunities and put Barca top of the table ahead of Real Madrid's trip to Villarreal.
Things should have been far better for Atletico, though, as they looked as fluid as they have all season during the first half and carved out a series of strong chances, with Yannick Carrasco, Godin and Antoine Griezmann all going close.
But the home side failed to make the most of their openings and Barca grew into proceedings, threatening Atletico with a few fine chances of their own towards the end of the half.
Atletico's ineffectiveness in front of goal was capitalised on when Rafinha opened the scoring just after the hour mark, though Godin headed the home side back on level terms.
However, just as he did against Leganes last time out in La Liga, Messi struck at the death to move Barca on to 54 points and back to the summit, where they will stay if Real Madrid fail to beat Villarreal later on Sunday.
Atletico made it clear from the start that they are not giving up on a La Liga title push and they went close twice inside opening five minutes.
Carrasco was the first to spurn a chance, inexplicably failing to hit the target from six yards out when Saul Niguez's cross landed perfectly for him.
Godin – returning after injuring his hamstring against Barca on February 7 – then prodded over from a similar distance following a corner.
Atletico's high intensity approach prevented Barca from gaining a foothold and Griezmann twice tested Marc-Andre ter Stegen – first from close range and then seeing his fierce 25-yard drive acrobatically tipped over by the German.
Jan Oblak was similarly sharp upon his return from two months out with a dislocated shoulder, tipping a Messi free-kick over before clutching Gerard Pique's goal-bound header on the stroke of half-time.
Barca's improvement continued at the start of the second half and an intricate, flowing move should have given them the lead, but Luis Suarez scuffed wide when played through by Messi.
Atletico then swiftly crafted another chance of their own, though Griezmann slammed an effort straight at Ter Stegen after being fed into the left side of the box, instead of squaring to Kevin Gameiro for an easy finish.
Barca capitalised on that let-off in the 64th minute, as Suarez's charged-down shot fell kindly for Rafinha and the Brazilian tucked a neat finish inside the left-hand post from close range.
Their joy appeared to be short-lived, as Godin glanced a header in from Koke's free-kick delivery in the 70th minute.
But the visitors had the final say.
Messi collected a cut-back from Suarez and, despite seeing his initial shot blocked, the ball dropped nicely for him once again and he coolly poked past the helpless Oblak to stun Atletico.