Lionel Messi’s late penalty ensured a bedraggled Barcelona scraped a 2-1 victory over Leganés in La Liga at a divided Camp Nou as the champions looked as if they had still not recovered from their humiliating midweek defeat by Paris Saint-Germain.

Messi scored both Barça goals, slotting home the crucial 90th-minute spot-kick, to earn an undistinguished win that keeps their title hopes flickering. However, it was another tough night for their coach, Luis Enrique, who was booed by some of the home fans.

Messi, anonymous in the 4-0 Champions League defeat at PSG, put Barcelona ahead in the fourth minute but Leganés were rewarded for a bold approach that resulted in them creating numerous chances when Unai López equalised in the 71st minute after an error from Sergi Roberto.

Neymar won a penalty late on which Messi converted to steal the win for Barça, keeping them within reach of the leaders, Real Madrid, and temporarily easing the pressure on Luis Enrique. He was jeered by a large number of the home supporters but received roaring approval from the most vocal section.

The win leaves Barcelona second in the table on 51 points, one behind Real, who have two games in hand on the Catalan club and Sevilla, who are third on 49.