Ronald Koeman's men had missed a chance to take advantage of Atletico's slip-up against Levante at the weekend when they were held at home by struggling Cadiz.
Barcelona was not at its best in a clash with another relegation-threatened side in Elche, but Messi's delightful double and a stylish Jordi Alba effort secured a crucial win.
Barca remains third in the table having played a game more than Atletico, whose lead over second-placed Real Madrid is just three points.
Francisco Trincao forced Edgar Badia into a close-range save in the second minute and, after Lucas Boye had spurned a gilt-edged chance at the other end, the Portugal international was denied a stunning goal by the Elche goalkeeper.
Trincao jinked past two Elche defenders after latching on to a pass from Messi, only to see Badia produce a fine diving save with his left hand.
Badia was required again to keep out Frenkie de Jong's header from a floated Messi free-kick, the frustration clear among Koeman and his players as parity was preserved.
That parity lasted just three minutes into the second half, Messi's shot squirming into the net despite Badia getting a hand to it after a superb flicked return pass from Martin Braithwaite.
Messi's second was similarly aesthetically pleasing, De Jong finding him at the end of the slaloming run before the Argentine delicately dinked the ball over Badia.
The game was put beyond any doubt in the 73rd minute when Braithwaite nodded Messi's excellent cross-field ball into the path of Alba to dispatch with an acrobatic effort.
The scoreline could have been made more emphatic late on, but substitute Antoine Griezmann cracked the crossbar from Sergino Dest's low cross.