The host dominated most periods of the first half as they had more ball possession and pressing but were stuned by Messi’s 36 minute header and a red card in the second half.
Barca thought they had taken the lead after three minutes, but saw Neymar’s effort correctly disallowed for offside.
Ajax looked more lively on the break and threatened an opener when Lucas Andersen fired wide following a poor clearance from Dani Alves.
The hosts’ wingers – Anwar El Ghazi and Lasse Schone – most especially, were outstanding nemesis to Barca’s defence and caused problems late on, while Davy Klaassen forced recalled goalkeeper Marc-Andre ter Stegen into a wonderful stop with his left-footed volley after 26 minutes.
Barcelona were fortunate for escaping conceding a penalty when Jordi Alba handled Anwar El Ghazi’s shot inside the box, and the full-back had his side’s first shot on target shortly after, but Cillessen was equal to to the task.
However, Barca took the lead on the 36th minute when Cillessen, having kept out Messi’s free-kick, raced to the left edge of his area to gather a bouncing ball, only to be beaten to it by the alert Marc Barta.
The Spaniard picked out Messi and the forward jumped beautifully to head an effort past Ricardo van Rhijn on the line.
Luis Enrique’s side looked sharper and more relaxed after the interval and Luis Suarez should have doubled the advantage when one-on-one with Cillessen after a clever pass from Messi but the Uruguayan was superbly denied a first Barca goal against his former team by the Ajax shot stopper.
Arkadiusz Milik saw his diving header rebound off Ter Stegen’s right-hand post shortly after the hour, but Ajax’s comeback hopes were dented when Veltman was shown a second yellow card for bringing Messi down, having previously been booked for a foul on Neymar in the first half.
The visitors didn’t waste much time before capitalising on their extra man when Messi got his second goal of the night, the 71st of his career equalling the legendary Raul Gonzalez as the all-time top goal scorer in the history of the competition.
La pulga got on the end of Pedro’s cross from the right and produced a perfect finish on the 76th minute as Barca provided the perfect answer to back-to-back La Liga defeats. The Argentine could have gotten a hat-trick but was denied by Ajax keeper.
AFC AJAX 0-2 FC BARCELONA
Goals: Messi 36′, 76′
Assists: Bartra, Pedro
Yellow Cards: Mascherano, J. Alba, D. Alves (Barcelona), Anwar El-Ghazi, J. Veltman, Niclas Moisander (Ajax)
Red Card: Joel Veltman
Ajax: Jasper Cillessen; Van Rhijn, Veltman, Moisander, Boilesen; Klaassen, Andersen (80′ Riedawald), Serero (83′ Denswil), Sigthorsson (62′ Milik); Schoene, El-Ghazi
Barcelona: Ter Stegen; Alves (83′ Adriano), Mascherano, Bartra, Alba; Xavi, Busquets, Rakitic (80′ Rafinha); Suarez, Messi, Neymar (75′ Pedro)