Raul Baena scored the decisive goal as Espanyol edged out 10-man Real Mallorca 3-2 in Friday night's tussle between two Primera Division strugglers.
Simao Sabrosa gave the home side the lead but strikes from Giovani Dos Santos and Javi Marquez put Mallorca in the driving seat at half-time.
Joan Verdu then levelled things up again with a penalty and, after the visitors saw Antonio Luna sent off, Baena ensured the points would stay at the Estadi Cornella-El Prat with his late effort.
The win sees Espanyol continue their climb away from the foot of the table, with the Barcelona-based club now four points clear of the relegation zone.
Mallorca, however, have won just once in 11 league matches and remain lodged in the bottom three.
It took 16 minutes for either side to register a shot, but when one arrived it resulted in the opening goal for Espanyol.
Baena was upended by Michael Pereira outside of the area, and Simao smashed the subsequent free-kick low into the net from 25 yards.
Mallorca finally mustered a shot through Dos Santos eight minutes later but he fired high over the bar.
However, the Mexican forward was more accurate with his next effort in the 36th minute, despatching a left-footed strike into the bottom left corner.
Mallorca's confidence was growing now and Dos Santos could have had a second seven minutes later but his shot was tipped around the post by home goalkeeper Francisco Casilla.
The visitors took the lead from the resulting corner, though, with Dos Santos whipping the ball to Javi Marquez, who found the target with an unstoppable volley from the edge of the area.
Espanyol showed a marked improvement at the start of the second half and came frustratingly close to an equaliser after 56 minutes when Hector Moreno's close-range header struck the crossbar.
Substitute Samuele Longo produced another good chance for the hosts 10 minutes later with a teasing drive which had to be pushed away by Ruben Mino in the Mallorca goal.
However, Longo was at the centre of Espanyol's equaliser after 68 minutes when he was sent tumbling to the floor by Jose Carlos Nunes to win his side a penalty, which Verdu confidently placed into the bottom left corner.
Things went from bad to worse for Mallorca nine minutes from time when Luna saw red after picking up his second booking of the contest for a foul on Sergio Garcia, adding to the yellow card he was shown at the end of the first half.
And Espanyol took advantage within minutes, with Baena powering a shot high into the net from a few yards out.
Longo could have added a fourth in stoppage time but saw his 12-yard strike blocked on the line by Mino.