Lionel Messi now has 26 goals this season, in his last eight games, he has seven goals and eight assists after 33 appearances.
Messi was hauled to the ground in the first half by a diving Unai Bustinza wrapping two arms around his waist and he was knocked over again in the second, this time earning a penalty, which he converted.
Leganes have dropped to the bottom of the table and look doomed to relegation, their chances of survival damaged by Barcelona snatching away their top scorer Martin Braithwaite as an emergency signing in February.
Leganes were not alone in feeling the rule had hurt them disproportionately and their sense of injustice might have been deepened by the fact Braithwaite was left on the bench for the entire 90 minutes.
Champions League- chasing Getafe slip up earlier, Getafe dropped more points in the race for Champions League qualification as they failed to break down Espanyol despite their opponents playing most of the match with 10 men.
Getafe stay fifth, level on points with fourth placed Real Sociedad, who will play their game in hand at Alaves on Thursday.
Getafe could also be overtaken if Atletico Madrid win on Wednesday against Osasuna.
A goalless draw represents a missed opportunity for Jose Bordalas’ side and they could even have lost to Espanyol, who had Bernardo Espinosa sent off in the 16th minute but are building momentum.
Espanyol move to within two points of safety after resuming with a 2- 0 victory over Alaves on Saturday.
Villarreal stayed in the hunt for the European places by beating Real Mallorca 1- 0.
Carlos Bacca’s early finish leaves Villarreal seventh, three points from fourth and Mallorca remain 18th.
Barcelona controlled possession in the first half but created little and would have been behind early on if Guerrero had been more precise.
First, Javier Eraso sprinted clear and despite taking too long to shoot, the ball spilled out for Guerrero, whose drive hit the foot of Clement Lenglet on the line.
Guerrero had another go moments later, this time from an acute angle, but his rasping half volley flew across the area and shaved the far post.
The 17 year old, Ansu Fati had earlier given Barcelona the lead, continuing his breakthrough season with a fifth goal in eight league starts.
Yet in the 69th minute, Messi gave his team the cushion they wanted, earning a dubious penalty with a storming run.
He won the ball on the halfway line, nutmegged one defender and held off two more.
After an exchange with Luis Suarez, he was finally knocked over, even if it appeared less of a foul than the previous attempts to stop him.
Messi curled into the bottom corner.
Suarez had come on for Fati and Sergio Busquets , Gerard Pique, Arthur Melo all departed too as Setien turned his attention to Sevilla.
Leganes coach Javier Aguirre was sent off for his protests in injury time .