Levante moved up one spot from the bottom of the ladder, but the Valencia club remains three points from safety ahead of the weekend matches in Spain's top flight.
For Sociedad. the dramatic defeat dented its own chances of qualifying for the UEFA Champions League. It remains in sixth place, five points behind Atletico Madrid, which occupies the fourth and final qualification spot, and Barcelona and Real Betis will also have a say on which team finishes there when they play each other on Sunday (AEST).
Jorge Miramon opened the scoring for the Levante in the 53rd minute, but David Silva equalised for Sociedad in the 66th.
However the late spot kick gave Melero the chance to win it for a desperate Levante, and he kept his nerve to convert the opportunity and keep faint hopes flickering for the home fans.