Roofe opened the scoring in the 63rd minute when he sneaked between defenders Jack Robinson and Jake Bidwell to head home Ezgjan Alioski’s cross.
And the 24-year-old struck again five minutes later, this time by firing home from close range after being found by Pawel Cibicki’s cross from the left.
Leeds were cruising before a terrible mistake by keeper Felix Wiedwald led to a freak goal for Pawel Wszolek.
After Luke Freeman’s 90th-minute corner was cleared as far as the Pole, Wszolek lifted the ball back into the box, where Wiedwald inexplicably misjudged the bounce and was then unable to prevent the ball crossing the line after it sailed over his head.
But Roofe completed his hat-trick in the final seconds, cutting in from the left-hand edge of the penalty area and shooting past keeper Alex Smithies.
It took Roofe’s goal tally for the season to nine and sealed Leeds’ first win in London since March 2015.
Struggling Rangers, whose defensive injury problems led to captain Nedum Onuoha being selected just days after returning to training following nearly three months out with a torn hamstring, have now lost five of their last six matches.
Roofe was a thorn in their side from the start - Smithies had to claw away a dangerous left-wing cross from the midfielder in the opening stages.
At the other end, Wszolek got to the right-hand touchline and pulled the ball back towards former Leeds man Matt Smith, who was denied a simple close-range finish by a superb challenge from Luke Ayling.
Right-back Ayling was also effective going forward, delivering an accurate first-half cross for Caleb Ekuban, who headed over.
Early in the second half, Josh Scowen sent an effort well wide and Bidwell headed wide of the near post from Freeman’s free-kick.
Cibicki, on as a substitute for the injured Ekuban, did get a shot on target but it was easily gathered by Smithies.
However, Smithies was left helpless when Alioski’s terrific cross set up Roofe for the opener.
After Massimo Luongo went close to equalising with a header from Bidwell’s cross, Roofe’s second goal appeared to crush Rangers’ hopes of a comeback.
They were given hope by Wiedwald’s error, but the outstanding Roofe had the final word.