Lionel Messi's late penalty saw bedraggled Barcelona scrape a 2-1 victory over Leganes on Sunday at a divided Nou Camp as the La Liga champions looked as if they had still not recovered from their harrowing midweek defeat to Paris Saint-Germain.

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

Messi, anonymous in the 4-0 Champions League defeat at PSG, put Barca ahead in the fourth minute but Leganes were rewarded for a bold approach which saw them create numerous chances when Unai Lopez levelled in the 71st minute after a huge error from Sergi Roberto.

Neymar won a penalty late on which Messi converted to steal the win for Barca, keeping them within reach of 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.

Andre Gomes, who has failed to live up to his €35m price tag since joining from Valencia in the summer, also came under fire and had to listen to a barrage of boos when hauled off for Andres Iniesta 10 minutes from time.

Luis Enrique urged the fans to stick by the team.

"I have nothing to say about criticism towards me because I can take decisions regardless of what the atmosphere is like, but players need to receive the backing and encouragement of the supporters," he told reporters.

"I regret the whistles towards Andre as we are much stronger when the fans are behind us. I don't understand why you would boo a player from your team. Everyone is free to express their anger how they like but booing doesn't make sense.

"What helps is when the fans support us, which is what happened in the end and helped us get the win."

Luis Enqirue was jeered by certain sections of the Barcelona support (Getty)

The nervy victory keeps Barca within a point of leaders Real Madrid, who have two games in hand.

Luis Enrique conceded another slip up could have done real damage to their confidence.

"We got three points today that are absolutely vital to keep going in the title race, a slip up would have been almost definitive, not in terms of points but on an emotional level," he said.

Barcelona celebrate following Messi's late penalty (Getty)

Barca will be tested again next week at Atletico Madrid but the coach said he trusted his side to turn things around.

"I'm sure we're going to improve immediately and you'll see that at the Calderon," he added.

"I cannot fault the attitude of my players, their effort or sacrifice or intensity, it has not been better in any other season. Of course things are not quite going our way but we're trying to change that."