Barca hit the crossbar and Atletico struck a post, while Marc-Andre Ter Stegen and Jan Oblak displayed why they are two of the best goalkeepers in the world as the game appeared to be heading for a draw.
But Messi had other ideas in the 85th minute, beating Oblak with a composed finish from the edge of the area to ensure Barca leapfrogged Real Madrid to the summit on goal difference.
Sevilla had briefly gone second thanks to a 1-0 triumph over Leganes, with Diego Carlos choosing a prime moment to open his account for Los Nervionenses.
Athletic Bilbao's good form continues – the Basque outfit dispatched free-falling Granada 2-0 with a Raul Garcia penalty and a late Yuri Berchiche goal at San Mames.
Elsewhere, Osasuna came from behind to conquer relegation-threatened Espanyol 4-2.
Marc Roca's 20th-minute spot-kick was cancelled out by Ruben Garcia before Ezequiel Avila, Jon Moncayola and a late Roberto Torres penalty pushed Los Rojillos well clear, despite Facundo Roncaglia's dismissal leaving them a man down. Right at the death, Jonathan Calleri provided some consolation for the hosts with his first goal for the club.
Getafe thrashed Levante 4-0 as Leandro Cabrera, Jorge Molina Vidal, Angel Rodriguez and David Timor all got on the scoresheet.
Borussia Monchengladbach returned to the top of the Bundesliga following a 4-2 home victory against Freiburg.
Breel Embolo scored twice – he would have had a hat-trick if not for his second-half penalty miss – while Marcus Thuram and Patrick Hermann also helped the Foals leapfrog RB Leipzig.
Jonathan Schmid hit an early leveller for sixth-place Freiburg, for whom Lucas Holer also notched.
Milot Rashica opened and closed the scoring as Werder Bremen pulled away from the bottom three with a 3-2 win at Wolfsburg.
Rashica's penalty was cancelled out by Wout Weghorst, with Leonardo Bittencourt re-establishing the Werder lead only for William to peg them back midway through the second half. With seven minutes left, Rashica turned home an assist from Maximilian Eggestein.
Inter Milan beat Spal 2-1 to take advantage of Juventus' failure to beat Sassuolo and go top of Serie A.
Lautaro Martinez's first-half brace, to which Spal's Mattia Valoti would reply after the break, ensured Inter made their best ever start to a top-flight season by clinching a 12th win from 14 opening games.
Earlier, Juve had needed a Cristiano Ronaldo penalty to force a 2-2 draw with Sassuolo, who had 18-year-old keeper Stefano Turati making his debut.
Leonardo Bonucci gave the Bianconeri the lead but Jeremie Boga beat Gianluigi Buffon with a chip to equalise before Francesco Caputo capitalised on a Juve error to give Sassuolo the lead. Ronaldo then converted a spot-kick to divide the spoils after Filippo Romagna fouled Paulo Dybala in the box.
Lazio consolidated third place after thumping Udinese 3-0 with two goals from Ciro Immobile and a Luis Alberto penalty, while an 89th-minute winner from Theo Hernandez saw AC Milan squeeze past Parma 1-0 at the Ennio Tardini.
Roma are fourth following a 3-1 success at Hellas Verona, where Justin Kluivert, Diego Perotti and Henrikh Mkhitaryan all notched to cancel out the effect of Davide Faraoni's goal.
Napoli are now winless in six following a 2-1 home defeat by Bologna. Fernando Llorente fired Carlo Ancelotti's men ahead but the Rossoblu hit back through Andreas Skov Olsen and Nicola Sansone.
Toulouse remain rooted to the bottom of Ligue 1 following a 2-1 defeat at Nantes.
Abdoulaye Toure's penalty and a Ludovic Blas strike were enough for the Canaris, although Toulouse's Aaron Leya did halve the deficit from the spot in second-half stoppage time.
Rennes beat St Etienne by the same scoreline, coming from behind to win it through Raphinha and Damien Da Silva following Lois Diony's opener for Les Verts.
The evening clash between Monaco and Paris St Germain was postponed due to adverse weather in the principality.