Barcelona moved into second place in the standings with an important win over Sevilla although they paid the price of the win as three players picked up suspensions.
The victory saw Barca leapfrog Atletico Madrid into second place on 16 points, two behind leaders Real who they meet in three weeks at the Camp Nou.
Luis Suarez gave the champions the lead with an outstanding bicycle kick in the 27th minute and Chile midfielder Arturo Vidal then got a crucial touch on a tame shot from Arthur Melo to double Barcelona's lead in the 32nd.
Arthur showed patience on the edge of the area in search of options. He found a great option in Vidal making a run through the middle and he found him with a perfectly placed over the top ball that the Chilean redirected into the back of the net.
Dembele, who was named in the starting lineup ahead of €120 million ($131.76m) signing Antoine Griezmann, made it 3-0 in the 35th with a superb solo dribble and finish.
Barca captain Messi scored from a free kick in the 78th to finally get off the mark in a season which has been blighted by injuries but there was a sour end to the game for Ernesto Valverde's side, who are two points behind Real.
Lopetegui's last visit to the Camp Nou was a painful affair as his Real Madrid side were hammered 5-1 by Barca in his final game in charge before being sacked, and this was a similarly galling experience for the former Spain coach.
His Sevilla side created three clear chances to take the lead at the Camp Nou but missed them all, as Dutch striker Luuk de Jong was thwarted by Barca keeper Marc-Andre ter Stegen and then missed the target, as did Brazilian midfielder Fernando.
With five minutes left to play, Pique picked up his fifth yellow card this season, ruling him out against Eibar. Lahoz showed more of his true colors in the dying minutes of the match, showing two straight red cards to Araujo and Dembele - the first for a slight tug, the second for a complaint about the slight tug. Barcelona secured three big points against Sevilla but will be going to Eibar severely shorthanded due to the key players’ suspensions.