Messi scored two stunning free kicks to make it 23 derby goals, while fellow forwards Dembele and Luis Suarez also registered at the RCDE Stadium.
The result has seen Barcelona move three points clear at the top of La Liga, while Espanyol, who have lost their last four league fixtures, remain down in ninth.
The first half-chance of the match fell to Espanyol in the ninth minute, but the home team's leading scorer Borja Iglesias could only fire his effort wide of the post.
Barcelona were having all of the ball though, and the visitors made the breakthrough in the 17th minute when Messi curled a stunning long-range free kick into the top corner of the net.
Luis Suarez - back in the team following a knee problem - had the opportunity to send Barcelona two goals ahead four minutes later when he met a clever pass from Messi, but Diego Lopez was on hand to make the save.
Barcelona did make it 2-0 in the 26th minute, however, when Dembele worked his way into the Espanyol box before finding the far corner with an excellent effort.
The Spanish champions were utterly dominant in the first 30 minutes of action, but Espanyol did have chances to register before the end of the first period, with Marc Roca having a strike deflected wide and Oscar Duarte coming close on two occasions with headers.
Luis Suarez then came incredibly close to getting his name on the scoresheet in the 36th minute, but the Uruguay international's effort from a Messi pass hit the Espanyol post.
Less than one minute later, Barcelona hit the post again, with Messi heading against the woodwork after Espanyol stopper Diego Lopez had excellently denied Ivan Rakitic from close range.
Hernan Perez headed over the crossbar late in the first period as Espanyol searched for a route back into the match, but Barcelona all but secured the points in the final minute of the half.
Dembele was again involved for the Spanish champions, with the Frenchman's through pass releasing Luis Suarez, who squeezed a low attempt through the legs of Diego Lopez.
Espanyol started the second period on the front foot, but aside from a Sergi Darder attempt which missed the crossbar, the home supporters did not have too much to shout about.
Diego Lopez had to keep out a close-range Messi effort just before the hour, before Perez tested the reactions of Barcelona goalkeeper Marc-Andre ter Stegen down the other end of the field.
Leo Baptistao was introduced in the 60th minute as Espanyol looked for a route back into the match, but Barcelona continued to resist the pressure, with Ter Stegen not having too much to do.
Sergio Garcia was next off the Espanyol bench in the 63rd minute, but Barcelona made it 4-0 in the 65th minute when Messi sent yet another stunning free kick into the top corner of the net.
Messi was prevented a hat-trick by a smart Diego Lopez save in the 69th minute, and Espanyol thought that they had registered in the 73rd minute when Duarte converted a Sergio Garcia free kick. VAR disallowed the defender's effort for offside, however, as groans erupted around the stadium.
Victor Sanchez headed over the Barcelona crossbar 10 minutes from time as Espanyol continued to search for a goal, and it almost arrived when Baptistao struck towards the far corner, but the ball just deflected wide.
Baptistao then headed into the arms of Ter Stegen in the final moments as the match ended 4-0, with Barcelona far too strong for their rivals on the night.
ESPANYOL (4-3-3): Diego Lopez; Javi Lopez, David Lopez, Duarte, Vila; Sanchez, Roca, Darder (Granero 77'); Perez (Baptistao 60'), Iglesias, Melendo (Sergio Garcia 63')
BARCELONA (4-3-3): Ter Stegen; Semedo, Pique, Lenglet, Alba; Vidal, Busquets, Rakitic (Denis Suarez 82'); Dembele (Coutinho 68'), Luis Suarez (Munir 79'), Messi