Barca have already been confirmed as Spanish champions, but Getafe are chasing fourth position, and the defeat at Camp Nou - coupled with a win for Valencia - has seen the capital outfit drop into fifth spot ahead of Week 38.
El Geta had a wonderful chance to take the lead in the 11th minute when Jorge Molina found all sorts of space inside the Barca box, but the experienced forward somehow missed the goal occupied by Jasper Cillessen, who started with Marc-Andre ter Stegen named on the bench.
Getafe thought that they had taken the lead in the 26th minute when Molina raced through and found the bottom corner with a super finish, but the striker was just offside, and that was confirmed following a VAR review.
Molina then missed the post with a curling effort in the 29th minute during a very strong period for the visitors, who were looking the more threatening in the final third of the field.
Ivan Rakitic twice had attempts in the period that followed, but the Croatian's first effort was wide of the post before Soria made a smart save to his left.
Barca found the opening goal in 39th minute, though, when Vidal converted from close range after Gerard Pique had seen his header from a Messi free kick saved by Soria.
Angel swept wide of Cillessen's post as Getafe looked to answer back late in the half, before Soria had to make a brilliant save to keep out a powerful Malcom effort down the other end of the field.
Barca started the second half on the front foot, and Vidal turned a deep Coutinho cross just wide of the post in the 53rd minute with the home side looking to double their advantage.
Francisco Portillo had been introduced for Getafe at the interval, but there is no question that the visitors were missing their leading scorer Mata, who was unavailable through suspension.
Soria did well to keep out a chipped effort from Messi in the 55th minute, before the Getafe goalkeeper made an even better stop to prevent Malcom from smashing home from close range in the 58th minute.
Wonderful defending from Leandro Cabrera then prevented Messi finding the back of the net in the 65th minute, with the centre-back somehow sprinting back to clear the attacker's effort off the line.
Getafe struggled to carve out chances in the second period, but Angel had a goal-bound strike deflected behind in the 71st minute, before the forward headed over the Barca crossbar 15 minutes from time.
The fact that El Geta had to commit players forward in search of a leveller meant that there was space for Barca down the other end, but a couple of crosses bounced off Messi inside the box.
Soria made two smart saves from Abel Ruiz and Messi late on, before Molina passed up an incredible chance for Getafe to level - heading against the post from close range.
As it transpired, Barca were to score a second late on, with Messi converting from close range after a clever pass from Sergi Roberto had released the Argentine into a dangerous position.
Barca will finish their La Liga season at Eibar next weekend, before facing Valencia in the Copa del Rey final on May 24. Getafe, meanwhile, will be looking to snatch back fourth when they host Villarreal.
BARCELONA (4-3-3): Cillessen; Roberto, Umtiti, Pique, Alba; Rakitic (Alena 62'), Busquets, Vidal; Coutinho (Ruiz 68'), Messi, Malcom (Semedo 78')
GETAFE (4-4-2): Soria; Damian, Djene, Cabrera, Olivera; Foulquier (Saiz 75'), Maksimovic, Arambarri, Shibasaki (Portillo 46'); Molina, Angel (Duro 86')