The Colombian cancelled out Sergio Ramos' opener with just five minutes remaining to leave the the championship in the hands of both Atletico and Barcelona
At no point did it look like being a straightforward match for Carlo Ancelotti's men - now four points behind leader Atletico Madrid with two games remaining - as Madrid endured a difficult start when Cristiano Ronaldo was forced off injured with just nine minutes gone.
The 29-year-old's suspected muscle strain could potentially see him ruled out of the Champions League final against Atletico on May 24 and, worryingly for Ancelotti, Madrid looked short of attacking quality without its talisman.
The visitors did, however, take the lead towards the end of the first half as Sergio Ramos took over free kick duties in Ronaldo's absence. The defender curled a precise effort in from 25 yards, but the visitors looked a shadow of their normal selves in the second period.
Humberto Osorio grabbed a goal for the home side five minutes from the end, heading in the equalizer and moving Valladolid out of the bottom three.
Ancelotti suggested in the build-up that there would be more twists and turns to come in the title race, and Valladolid almost made that prophecy become reality in just the fifth minute.
Zakarya Bergdich produced a burst of pace on the left flank before crossing into the danger area, but Guerra's glancing header went agonizingly wide of the right-hand post.
The Madrid giants were dealt a major blow three minutes later as Ronaldo was forced off. Ancelotti's men appeared dejected and allowed Valladolid another chance with 18 minutes played, but the off-balance Oscar Garcia blazed over following Antonio Rukavina's cut-back.
Los Blancos eventually came to life and were duly rewarded with the opener after 35 minutes.
Xabi Alonso's clever turn on the edge of the area drew a foul from Victor Perez and Ramos – in place of usual free kick specialist Ronaldo – curled the resulting set piece into the roof of the net, despite Jaime's best efforts in goal.
Madrid seemed more willing to invite pressure at the start of the second period, but Valladolid still struggled to force Iker Casillas into action in his first La Liga start since January 2013.
At the other end, Karim Benzema skewed wide from close range after connecting with Nacho Fernandez's right-wing cross.
Guerra narrowly missed the target with a superb improvized overhead kick before teammate Osorio made amends late on, heading Oscar's corner into the net to leave Madrid's title challenge in tatters.