Barcelona defeated lowly Mallorca 2-1 on Sunday to snap a three-match losing run at Camp Nou in all competitions as it climbed to second in la liga behind champions Real Madrid.

With Real already having secured a record-extending 35th la liga title on Saturday, Barcelona made sure the disappointment of being out of the running for the top prize did not distract it from the job at hand.

Memphis Depay's first-half strike calmed nerves at Camp Nou, where almost half the seats remained empty as fans disappointed with their team's showing this season opted to stay away.

Captain Sergio Busquets extended its lead early in the second half from a rebound.

Mallorca defender Antonio Raillo took advantage of a lapse in Barca's defense to fire home a consolation from close range in the 79th minute.

Xavi Hernandez's team leapfrogged Sevilla to second in the standings. It is two points ahead of Julen Lopetegui's side with 66 points.

With four games left, champions Real hold an unassailable 15-point lead over Barca. Mallorca is 16th with 32 points, a point above the drop zone.

Arsenal earns crucial win at West Ham in top-four hunt  

"It’s very frustrating seeing Real Madrid win the league so early and with such an advantage,” midfielder Frenkie de Jong told Movistar Plus. "But we have to admit that we struggled this season, didn’t play to our standards and were not able to compete with them. I hope next season things change for the best."

Barcelona is now in a close race with Sevilla and Atletico Madrid to secure second spot in laliga, with the three clubs separated by just five points.

The club that finishes second will earn an extra 3.4 million euros ($3.58 million) as they will feature in the Spanish Super Cup in Saudi Arabia.

Following a brilliant through pass by Jordi Alba, Depay fired Barcelona ahead in the 25th minute with a close-range finish.

The Catalans extended its lead early in the second half when Busquets controlled a rebound in a crowded area and found the space to drill the ball into the back of the net.

Mallorca’s goal came from nowhere and the final score made the match look closer than it was.

Teenager Ansu Fati was given a standing ovation when he made his first laliga appearance for Barca since November, coming on as a second-half substitute.

The 19-year-old has struggled to regain full fitness after suffering a number of injury setbacks over the past year.