(CNN) -- It was far from vintage Barcelona, but it was enough to keep alive the Catalan club's dwindling hopes of retaining the Spanish league title.
With white handkerchiefs waving in the Camp Nou to indicate the fans' frustration at what appeared to be another disappointing setback, Lionel Messi came to the rescue on Sunday to earn a 2-1 victory against Athletic Bilbao.
Having been knocked out of the Champions League, then losing the Copa del Rey final to Real Madrid, Gerardo Martino's team had been staring down the barrel of an unthinkable fourth successive defeat.
With Atletico Madrid having gone seven points clear at the top of the table with Friday's 2-0 win over Elche, it would've spelled disaster if Barca could not recover from Aritz Aduriz's opener for the fourth-placed Basques.
The early signs weren't good.
After Messi had a goal ruled out for offside, Aduriz hit the Barca woodwork with a spectacular overhead kick, then Alexis Sanchez smacked the Bilbao bar when it seemed easier to score.
Aduriz ghosted through Barca's frail defense to slot in a low shot five minutes after the break, and teammate Markel Susaeta had an effort ruled out for offside soon after.
To the home supporters' intense relief, Pedro provided the equalizer in the 72nd minute with his 15th league goal this season, diverting a low shot from Sanchez into the net from close range.
Soon after that, Messi picked himself up after being fouled on the edge of the penalty area and fired a free-kick through the wall.
It ended what, for the four-time world player of the year, was a goal drought -- four games without scoring -- as he netted for the 26th time in La Liga, leaving him third in the Pichichi standings behind Atletico's Diego Costa (27) and Real Madrid's Cristiano Ronaldo (28).
It proved to be the winner, though Barca needed Javier Mascherano -- who squandered a great scoring chance not long beforehand -- to make a brave block to stop a goal-bound Bilbao shot in time added on.
The result left Barca four points behind Atletico with four games to play -- the last of which will be between the two teams at the Camp Nou.
It lifted Barca into second place above Real, without a match this weekend ahead of Wednesday's Champions League semifinal first leg at home to Bayern Munich.
Atletico, meanwhile, will be seeking to make it an all-Spanish final as the capital team hosts English club Chelsea in Tuesday's opening leg.
Earlier Sunday, Sevilla consolidated fifth place with a 4-0 win at home to Granada, Rayo Vallecano moved up to mid-table safety with a 3-1 win that almost certainly condemned Real Betis to relegation, and Celta Vigo beat second-bottom Almeria 4-2.
In Germany, third-placed Schalke suffered a shock 3-1 defeat at Stuttgart which moved the home side four points clear of Hamburg in the relegation playoff place.
Fourth-placed Bayer Leverkusen moved to within four points of Schalke with a 4-1 win at second-bottom Nuremberg.
In France, second-placed Monaco clinched a spot in next season's Champions League with a 1-0 win at home to Nice, thanks to an early goal from former Manchester United striker Dimitar Berbatov.
It put Monaco seven points behind champions Paris Saint-Germain, who won the French League Cup on Saturday.
Third-placed Lille lost more ground, being held 0-0 at Marseille.
In Portugal, Benfica clinched a 33rd league title with two matches to play as Brazilian forward Lima scored both goals in a 2-0 win against Olhanense.
Benfica had been runner-up to Porto for the past three seasons.
Seven points back, Sporting Lisbon clinched Portugal's second Champions League place with a 1-0 win at Belenenses, with Porto in third another 11 points adrift with a game in hand.
In the Netherlands, PEC Zwolle caused a big shock by winning the Dutch Cup for the first time, coming from behind to beat league-leading Ajax 5-1.
Ryan Thomas and Guyon Fernandez scored twice to give the mid-table team a place in the Europa League qualifying rounds next season. It had lost its only other finals in 1928 and 1977.