La Liga Wrap: Late goal crucial for Sociedad
The last-gasp win lifted Sociedad to sixth in the Liga table, two points above Villarreal, who visit Malaga on Monday.
Fifth and sixth places earn a spot in Europe's second-tier competition and manager Jagoba Arrasate - who signed a two-year contract extension this week - will be hopeful his side can hang onto the position with less than a month of the season remaining.
They had to do it the hard way in San Sebastian on Saturday, after Jhon Cordoba turned in Diego Colotto's ball in the 23rd minute for Espanyol.
Sociedad's response was swift, although they required a slice of luck, with Manu Lanzarote's own goal nine minutes later coming after a corner.
Espanyol had plenty of chances in the second half to claim their first win in almost a month, but Sociedad held firm.
They then ramped up the pressure before the end, as Mikel Gonzalez, Haris Seferovic and Pablo Hervias all had late opportunities.
But just when it seemed they would have to settle for a point, Vela popped up, scoring with his left foot to end a neat team move and end Sociedad's three-match winless streak.
Valencia also left it late to claim a point in a 1-1 draw at struggling Osasuna.
Oriol Riera put the hosts in the lead in the 19th minute, following in after Roberto Torres' 25-yard effort was spilled by Valencia goalkeeper Vicente Guaita.
Substitute Jonas levelled for Valencia eight minutes from time, though, with his composed, angled finish extending their unbeaten run to three matches.
Saturday's other Liga fixture saw Getafe claim what could be a valuable point in a 0-0 draw at Levante.
Alexis Ruano was sent off for a second yellow card with nine minutes to play but Getafe held on, despite their numerical disadvantage, to pick up a draw.
They sit 18th and are now in the bottom three on goal difference only, although 17th-placed Real Vallodolid have a game in hand.