The result means that Quins will meet Leicester Tigers in the semi-finals, while Saints will face league leaders Saracens.
It took 15 minutes for the game's first points, but a Nick Evans penalty put Harlequins in front.
However, Northampton got themselves back in the game eight minutes later when Jamie Elliott scored a try for the visitors to take them into the break trailing 10-5.
It didn't take long after half time for the hosts to extend their lead with Rob Buchanan's try being added to by Evans's kick for a 17-5 score.
Tom Casson added a third Quins's try seven minutes later to make it 22-5.
Northampton scored again shortly after when Christian Day's try brought the away side within three points of drawing level.
Quins managed to hold on to secure a 22-19 win.