Right wing Tom Williams, hooker Rob Buchanan and centre Tom Casson scored tries for Quins, with fly-half Nick Evans landing two conversions and a penalty.
Saints, narrowly denied after rallying from 22-5 down, replied with tries from left wing Jamie Elliott, hooker Dylan Hartley and lock Christian Day, on his 100th appearance for the club.
Fly-half Stephen Myler converted two of the tries but had earlier missed two penalties and a conversion.
Harlequins leapfrogged Northampton to finish third on a day when the two sides, already assured of their play-off places, served up a feast of attacking rugby.
- Sports & Recreation
- Tom Casson
- Rob Buchanan
- Dylan Hartley