The Argentine scored twice - the second a brilliant run and finish - to send his side through in the Copa del Rey clash, but his Brazilian teammate suffered an ankle injury
Messi turned home Cristiano Tello's cross from close range at the end of the first half before a brilliant solo effort secured the win for Gerardo Martino's men, who lost Neymar at the half-hour mark to a worrying ankle injury.
Messi partnered Neymar and Tello in attack for Barca, which left Xavi - on the brink of his 700th appearance for the club - among the substitutes.
Getafe, meanwhile, handed a debut to youngster Carlos Vigaray at full back, while Adrian Colunga lead the line in place of Ciprian Marica.
Messi came within inches of handing Barca the lead after just four minutes, firing Neymar's cut-back just wide of the near post from the edge of the area.
The game was quiet for the first 20 minutes but Getafe created the best of the early chances, when Juan Rodriguez volleyed Pablo Sarabia's flick-on straight at Jose Pinto from point-blank range.
Barca controlled possession but was some way short of its usual rhythm, and the Blaugrana were dealt a further blow when Neymar was forced off after falling awkwardly and spraining his ankle when stretching to cross the ball.
Alexis was then stretchered off for the home side as the game showed little sign of sparking into life, but in the 44th minute, Barca finally found some attacking precision.
Tello was played in behind the full back Vigaray and his cross was met by Messi - just ahead of Rafa - who turned the ball past Codina and into the far corner.
Getafe started the second half brightly, with Colunga testing Pinto with a chip and Pedro Leon firing some dangerous crosses into the area, but Barca doubled its lead just after the hour mark thanks to the brilliant Messi.
Turning away from Rodriguez, he skipped clear of two challenges on the edge of the area before beating the onrushing Codina and slotting the ball home.
Messi was denied a third by Codina and Alexis fizzed a shot wide before Xavi came on to rapturous applause from the visiting fans, making his 700th Barca appearance in place of Cesc Fabregas.
Colunga drew a strong save from Pinto in the closing stages and Messi was denied a hat trick by a brilliant save from Codina, before Tello fizzed a shot over the bar from close range from the resulting corner, but Barca's passage to the quaterfinals was already secured and it will now face Levante in the last eight.