The Uruguay forward struck with 18 minutes to play at the Estadio de la Ceramica before Messi added a simple second, ending a run of back-to-back draws in the top flight for the Catalans and keeping the title race firmly in their hands.
Messi's goal saw him equal the record of 525 goals in all competitions for the same team in one of Europe's top-five leagues, set by Bayern Munich great Gerd Muller.
Luis Suarez and Gerard Pique each hit the woodwork but Marc-Andre ter Stegen was called upon to keep the home side at bay, before Raba's red card in the second half left Villarreal up against it.
The visitors had been short of their best but one moment of slick passing carved open the Villarreal defence and allowed Luis Suarez to break the deadlock, and Messi made the points safe with seven minutes remaining.
Pique hit the bar after only three minutes with a header from Denis Suarez's corner, though Ter Stegen had to be alert to deny Roberto Soriano from close range in an evenly contested first half-hour.
A Messi free-kick forced a save from Sergio Asenjo - back in the team in LaLiga for the first time this season after recovering from his latest knee injury - and the Argentina star flashed another shot narrowly wide, but it was a pretty subdued display from the leaders in the opening half.
Villarreal were not looking too stretched by Barca's approach play and Valverde responded by bringing off Denis Suarez for Paco Alcacer just before the hour mark, with the Catalans shifting to more of a 4-3-1-2.
Alcacer almost made an immediate impact, connecting with Jordi Alba's low cross only to be denied by Asenjo six yards from goal, before Messi sent another Alba pass inches wide of the right-hand post.
As Barca suddenly looked to be in the ascendancy, Raba handed them a huge advantage, lunging into a challenge on Sergio Busquets on the edge of the visitors' penalty area and catching him on the foot with raised studs, prompting referee Ricardo de Burgos Bengoetxea to brandish a straight red card.
Luis Suarez was inches from capitalising on that man advantage seven minutes later, nudging Alba's cross onto the right-hand post with an outstretched boot, but the Uruguayan at last made the telling impact in the 72nd minute.
Messi started a quick passing move that saw the former Liverpool striker play a one-two with Alcacer, round Asenjo and slot home for his seventh league goal of the season.
Manu Trigueros brought a flying stop out of Ter Stegen but Villarreal killed off their own hopes of a comeback with eight minutes left. A loose pass allowed Busquets to feed Messi on the edge of the area and the Argentina star burst into space and slotted the ball past Asenjo, securing a 12th win in 15 league games this season.