First-half goals from Marlon Pack and Jamie Paterson eased Bristol City's Championship relegation fears as they beat QPR 2-1 at Ashton Gate.
The home side took a 14th-minute lead when Matt Taylor's touch to a Joe Bryan cross set up Pack, who lashed in a right-footed volley from 15 yards.
Taylor was involved again as City doubled their advantage five minutes before the break. His control and pass allowed Paterson to break through the Rangers back-line and shoot past the advancing Alex Smithies from the edge of the box.
It was not until the last minute of stoppage time that Rangers hit back, substitute Idrissa Sylla shooting home from close range from a cross by fellow replacement Conor Washington. Lee Johnson's men fully deserved their victory and moved to within three points of Rangers in the table, four clear of the drop zone.
City started brightly and Paterson might have done better when shooting over from inside the box after six minutes after Taylor had passed up the initial opening. Pack soon got it right to fire home the opener, while Rangers only tested home goalkeeper Frank Fielding once in the first half.
The visitors did get the ball in the net after 38 minutes following a right-wing corner, but referee Jeremy Simpson spotted what looked a clear foul on Fielding. And instead the hosts went into half-time with a two-goal cushion thanks to Paterson's finish.
City could have sewn things up soon after the break when Paterson shot weakly at Smithies, having been given a clear sight of goal by Tammy Abraham's pass.
But there was a scare for the hosts moments later as Fielding produced a brilliant save, diving to his right, to keep out Yeni Ngbakoto's shot from a cross by Washington, a half-time substitute for Darnell Furlong.
Washington fired into the side-netting from 20 yards following some neat footwork as Rangers upped their game. But at the other end City continued to create chances. Abraham had a fierce shot deflected just over and Aden Flint had a header from a corner cleared off the line.
Josh Brownhill shot over from a good position after Johnson substituted both his strikers, with Monday's important game at Blackburn in mind.
Rangers kept battling and Fielding had to make a diving save to prevent the impressive Washington netting in injury time. Then came Sylla's strike, but there was barely time for City to kick off.
Bristol City boss Lee Johnson:
"I thought the attitude of all my players was first class. We won the battles and deservedly took the points. Nothing is decided yet, but I know my team and I have a good feeling about where they are at the moment.
"Nothing is settled yet and we have a hugely important match at Blackburn on Monday. We will go there to win the game, even though a point would not be a bad outcome.
"Frank Fielding has made one really important save for us today, but I thought the back four in front of him were outstanding. Now we have to take our home form into an away fixture. If we can do that we are capable of winning at Blackburn."
QPR boss Ian Holloway:
"How do you defend the indefensible. I like my teams to represent my character and I have never gone down with a whimper in my life. Some of the things I saw in the second half were incredible. When you are 2-0 down and you get a free-kick surely you run to the ball and take it as quickly as possible.
"Twice we allowed City players to pick the ball up and walk backwards with it. One got booked for time-wasting and the other didn't, but where was the fight from my players?
"People inside this ground know that when I wore the blue and white quarters (Bristol Rovers colours) I would never have allowed that sort of thing to happen. City didn't even have to work for their goals. We need another win to be safe and we have been trying to get it for four games now."