A scrappy game at Levante's Ciutat de Valencia stadium appeared to be heading for 0-0 draw until Iranian Masoud ghosted away from his marker in the 87th minute and curled a brilliant shot into the top corner.
Kike Sola, another substitute, added a second in the fourth minute of added time to leave Levante, who play Russian side Rubin Kazan in the Europa League last 16, in 10th on 34 points and in danger of missing out on a place in continental competition next season.
Levante midfielder Papakouly Diop was carried off the pitch earlier in the second half after a clash of heads with Osasuna's Emiliano Armenteros and the Senegalese was taken to a local clinic for checks, Levante said on their Twitter feed.
Levante enjoyed possession for 41.5% of the game.
Levante had eight shots, including three on target.
Obafemi Martins had two shots for Los Granotes, more than any of his team-mates.
Pape Diop went off due to injury in the 57th minute and was replaced by Barkero.
Loukas Vyntra's 18 passes to Pedro Ríos were the most between any Levante team-mates during the match.
- Sports & Recreation