The Mexican attacker scored a vital goal with the last kick of the match as Sociedad grabbed all three points.
Jhon Cordoba gave visiting Espanyol the lead in the first half, but the home side drew level when Sergio Canales scored a deflected goal with 32 minutes gone. Just when it appeared the game would end in a 1-1 draw, Vela worked some of his magic.
The Mexican attacker controlled a pass and beat defender Juan Fuentes, before finishing past goalkeeper Francisco Casilla with the last kick of the match.
The Mexican attacker's goal was his 13th league tally of the season, and 18th in all competitions. He also has 11 assists in the league for Sociedad this sason.
The win was a huge boost to Sociedad's Europa League hopes. Vela's side now sits sixth in La Liga, with the fifth, sixth and seventh placed sides all advancing to the Europa League next season.