United rode their luck to keep in touch with the Coca-Cola Championship leaders with on-loan Danny Webber hitting a brace - his third in as many games for the Blades - following Martin Rowlands' opener for the Londoners, with Kevin Gallen firing his 100th career goal.
Webber fired his second goal in successive matches just before half-time to haul out-of-sorts United level and cancel out Rowlands' 26th-minute strike for the visitors.
Webber headed a second soon after the break and Gallen punished Chris Morgan's defensive lapse midway through the second half to level before Gray's last-gasp spot kick settled it.
Blades fans, full of expectancy following the 4-0 Yorkshire derby romp at Elland Road, looked on with concern as Rangers made much the brighter start.
Danny Shittu had one early shot blocked by Chris Morgan, while United's only effort in the opening 25 minutes was a weak header from Liddell following Webber's cross.
Concern turned to dismay for the Bramall Lane faithful soon after when Georges Santos slipped the ball to Rowlands on the edge of the penalty area and the Rangers midfielder's right-footed shot deflected off Jon Harley inside home goalkeeper Paddy Kenny's near post.
The visitors continued to look the more likely before Andy Gray's header from Harley's cross was well saved by visiting keeper Simon Royce.
Kevin Gallen went close with a long-range shot for Rangers, while Alan Quinn fired over the top from 25 yards.
Then Webber single-handedly hauled the Blades level, surging into the penalty area two minutes before the break and holding off two challenges before firing a low shot beyond Joyce.
Rowlands limped off soon after and was replaced by Stefan Bailey.
The Blades looked a different side after the restart, Phil Jagielka forcing Royce into a fine save from 20 yards, the visiting keeper then denying Harley from close range.
But there was no denying Webber his third goal as his header from six yards gave United a 2-1 lead in the 53rd minute.
Warnock's side were now in control, but Kevin Gallen pounced to punish a defensive lapse.
Blades central defender Chris Morgan lost possession in his own penalty area and Gallen took full advantage to clinically despatch a right-footed shot into the top corner in the 66th minute.
But United continued to press, Gray forcing Royce into action again with a header from Harley's cross, before Rangers regained the initiative in the closing stages, forcing United to hold on.
Shittu went close with a well-struck free-kick and Bailey flashed a right-footed shot wide, while Webber was denied a hat-trick at the other end when Royce held his effort from the edge of the area.
Then with one last effort United charged forward. Santos was penalised for his challenge on Leigh Bromby and from the resulting free-kick referee Lee Probert penalised Rangers for pushing in the area and pointed to the spot.
Gray stepped forward in the 90th minute to power home the winner to keep United's play-off dream alive.