Cesc Fabregas gave the Catalans a two-goal lead before Messi turned on the style in stoppage time, netting twice including a magnificent solo effort to complete the scoring.
However, the Argentinean started the game on the bench with coach Tata Martino keen not to rush him back from a thigh injury too quickly ahead of Saturday’s title clash with Atletico Madrid. Neymar missed out through illness, meaning Fabregas, Andres Iniesta and Pedro made up the Barca front three.
The Catalans took the lead after just eight minutes when Fabregas met Pedro’s cut back cross at the back post to power a header into the opposite corner of the net.
At that point a high-scoring affair looked likely but Getafe responded well and could have drawn level when Juan Valera nodded over from inside the six yard box having jumped highest to meet Pablo Sarabia’s dangerous freekick.
Getafe were presented with another good opportunity to restore parity but Pinto produced a good save to tip Juan Rodriguez’s header from Jaime Gavilan’s freekick round the post.
Barcelona pressed for a second after the break, with Fabregas and Iniesta both seeing efforts saved by the busy Jordi Codina in the Getafe goal.
However Getafe’s resistance was finally broken when Fabregas added his second from the penalty spot, slamming his shot from 12 yards into the top left corner after Pedro had been felled in the box by Valera.
Messi was introduced just after the hour mark to a rapturous reception from the Camp Nou crowd, making his first appearance for Barcelona in over two months.
And rather predictably the Barca number 10 added his name to the score sheet, adding a third in the 90th minute by rolling the ball into the net from eight yards.
However he wasn’t finished there, scoring his second by picking up the ball on the halfway line and driving towards goal, beating three opposition players before finishing emphatically into the net. The result means Barcelona head into the second leg with a commanding 4-0 lead, giving them a boost ahead of Saturday’s La Liga showdown with Atletico