Messi opened the scoring after 20 minutes but there were no further goals in a scrappy first half and then Xherdan Shaqiri equalised for the hosts five minutes after the interval.
It looked destined to end in a draw until Messi put his side ahead again two minutes from time and then made sure of the triumph from the penalty spot.
The visitors had the bulk of possession in the first period, but only looked dangerous when Messi linked up with Manchester City striker Sergio Aguero.
The duo combined in the 20th minute, Aguero teeing up Messi for a cross-shot which flashed into the net.
Switzerland levelled the clash in the early stages of the second half, Shaqiri making no mistake with a left-footed finish when one on one with Argentina goalkeeper Sergio Romero.
Ottmar Hitzfeld's team looked set to hold on for a draw, but were made to pay for sloppy defending towards the end.
Messi seized on a poor pass from defender Francois Affolter, accelerated past Philippe Senderos and unleashed a fine shot to put Alejandro Sabella's team ahead.
Affolter was again at fault in stoppage time, fouling Gonzalo Higuain to hand Messi the chance to complete his treble from the penalty spot and the Ballon d'Or winner duly obliged.