The 19-year-old midfielder entered as an 89th-minute substitute and scored the winner four minutes later to give Valencia a 2-1 win over Valladolid, sending the home crowd into a frenzy at Mestalla Stadium.
The victory, Valencia's second in a row after a run of three losses and a draw, elevated the club to 16th place, two points clear of the relegation zone.
Guerra, who came through Valencia's youth squads and is touted as one of Spain's promising youngsters, beat a defender outside the area before sending a left-footed shot into the top corner for his first goal with Valencia's main squad.
Valladolid, sitting in 14th and coming off two straight victories, are two points ahead of Valencia with seven matches remaining.
The visitors opened the scoring through a Cyle Larin breakaway in the sixth minute.
Valencia equalised with a header by Mouctar Diakhaby in the 60th after Valladolid goalkeeper Jordi Masip misjudged the ball thinking it was going wide.
Valencia last played in the second division in 1986-87.
Villarreal defeated Espanyol 4-2 at home to move to fifth and stay in contention for the final Champions League spot. The win left the club five points behind fourth-place Real Sociedad.
Etienne Capoue scored twice for Villarreal, with Dani Parejo and Nicolas Jackson also getting among the goals.
Espanyol stay in second-to-last-place, four points from safety. They haven't won in eight straight matches, with seven losses and a home draw against Cadiz in the previous round.
Barcelona have an 11-point lead over defending champions Real Madrid at the top of the standings.