Harlequins RL (10) 22
Tries: Dorn, Randall, Purdham, McCarthy-Scarsbrook Goals: Purdham 3
Salford (14) 26
Tries: Wilshere 2, McGilvray, Nash, Swain Goals: Wilshere 3
Harlequins' play-off hopes took a massive dent after a late Luke Swain try gave struggling Salford a dramatic victory at the Stoop.
Quins looked set for a crucial win when second-half tries from Rob Purdham and Louie McCarthy-Scarsbrook put the home side 22-14 up with five minutes left.
But Salford turned the game on its head with tries from Steve Nash and then Swain in the closing moments.
Quins have now suffered eight defeats in their last nine games.
It is a huge turnaround in fortunes for a side that was sitting fourth in the Super League table back in June.
The opening quarter of the contest was pretty uneventful and it was not until 14 minutes that the deadlock was broken, John Wilshere pouncing after Jon Wells fumbled Stefan Ratchford's kick through.
Quins responded well and scored two tries in five minutes when Luke Dorn and Chad Randall both burrowed over.
The home side could not maintain their advantage, however, and Wilshere dived over in the corner for his second while Dean McGilvray raced the length of the field to score after intercepting Dorn's pass.
The game really opened up after the break and Quins carved out a handy cushion when Purdham ran a neat angle to stroll over on 45 minutes while McCarthy-Scarsbrook broke tackles on halfway to score near the sticks.
But Salford were not to be denied, their late scores ending a run of five straight league defeats.
Quins coach Brian McDermott:
"Once again we did not play well. I do not think we have a chance of making the play-offs, certainly not playing like that.
"There was a lot of poor decision-making out there, and that is a real problem.
"We had a side out there today good enough to beat Salford - and we should have beaten them. But there were some dumb decisions made, and that cost us."
Salford coach Shaun McCrae:
"When Harlequins scored late on I thought 'here we go again'.
"But when there is time left on the clock you always have a chance, and we proved that today.
"To score two tries in the last five minutes is pretty special, but I thought we thoroughly deserved to win.
"It is just a shame we are not in the running for the play-offs at all. We have lost too many games by just a few points - convert those into wins, and we would be up there.
"But there is still plenty of potential here, and we have to keep working at it."
Harlequins: Melling, Wells, Gafa, Clubb, Sharp, Dorn, Gale, Ward, Randall, McCarthy-Scarsbrook, Williamson, Golden, Purdham.
Replacements: Heckenberg, Kaye, Haggerty, Bryan.
Salford: Fitzpatrick, McGilvray, Littler, Henry, Wilshere, Smith, Ratchford, Cashmere, Alker, Leuluai, Sibbit, Adamson, Swain.
Replacements: Paul, Walton, Sidlow, Nash.
Referee: T Alibert (Toulouse)