Harlequins have leapfrogged Bath Rugby to claim the final playoff spot in the Aviva Premiership on the final day of the season.
Mike Brown put the home side ahead early on, but they were unable to secure a bonus point, as George Ford kept adding penalties for the visitors.
However, the victory leaves Harlequins with one more win over the course of the season, allowing them to clinch fourth place in the table.
League leaders Saracens slipped to just their third defeat of the season, losing to defending champions Leicester Tigers.
The hosts had a narrow lead at the start of the second half, but tries from Manu Tuilagi and Blaine Scully within 10 minutes of the restart set Leicester up for the win.
The victory ensures that they finish third in the table.
Second-placed Northampton Saints will head into the playoffs on a high after crushing London Wasps, scoring 11 tries in the 74-13 victory.
George North, Phil Dowson and Lee Dickson all added two tries, while Ken Pisi, Ben Foden and Sam Dickinson were among the other scorers.
Wasps had taken a 13-0 lead, but failed to add to their score after the opening quarter of an hour.
A brace of tries from Andy Fenby has given London Irish a narrow win over Sale Sharks in their final match of the season.
Mark Easter and Tom Arscott got Sale off to a good start, but Fenby and Marland Yarde put the home side in front in the second half.
Already-relegated Worcester Warriors bow out of the division on a high note as a late penalty gave them just their second win of the season.
Jonny May appeared to have done enough to give Gloucester Rugby the win, scoring two tries for the visitors, but Ryan Lamb added two penalties inside the last 15 minutes to give Worcester the win by a single point.
Exeter Chiefs secured an eighth-placed finish in the table with a comfortable win over Newcastle Falcons.
Luke Cowan-Dickie and Ben White both found the line for first-half tries, while Mark Wilson picked up the only try for the hosts in the final minute of the game.
Results in full: Harlequins 19-16 Bath, Leicester Tigers 31-27 Saracens, London Irish 22-20 Sale Sharks, Newcastle Falcons 13-23 Exeter Chiefs, Northampton Saints 74-13 London Wasps, Worcester Warriors 28-27 Gloucester