Harlequins flanker Tom Guest's late try kept his side's Premiership play-off hopes alive as they ended Exeter's slim chance of a top-seven finish.
Trailing 16-5 at the break, Quins led for the first time when Guest scored five minutes from the end.
Winger Ugo Monye responded to home tries by Dave Lewis and Matt Jess to keep his side in it before the break.
But Nick Evans, who kicked four goals, and Danny Care, under the posts, both crossed before Guest's decisive try.
Evans was unsuccessful with the boot for only the second time in the match with the touchline conversion attempt.
But, having trailed by 18 points with 35 minutes to go before staging their superb fightback, Quins saw out the game to move within three points of fourth-placed Bath heading into next weekend's final-day showdown between the two sides at The Stoop.
A Quins victory should be enough to ensure fourth spot but, thanks to the bonus-point system, Bath could actually lose and still qualify for the play-offs - if, in a high-scoring game, they went by less than seven points, scored four tries and kept Quins to less than four.
Exeter's seventh home reverse of the season, the most defeats they have suffered in a season since reaching the Premiership, meant that Wasps will now finish seventh and will play Stade Francais in a play-off for the final place in next season's European Challenge Cup.
But, following their heavy eight-try, 55-12 defeat by Sale in their last home game, they were pleased to restore some pride at Sandy Park.
Quins had to make two late changes to their already-named team as they pursued their goal of a place at Twickenham for the Premiership final on 31 May.
England full-back Mike Brown failed a late fitness test and was replaced by Ollie Lindsay-Hague, while Worcester-bound Sam Smith took a knock in a team run on Saturday, so Monye came in on the wing, replaced on the bench by Ross Chisholm.
That made a total of five changes to the side beaten by Northampton in last week's Amlin Challenge Cup semi-final.
Exeter head coach Rob Baxter:
"You are disappointed when you lose, but what we had asked the players to show was commitment and they did that in spades.
"It just shows that when you get most of the way you want to play and the quality is correct, then we are very competitive side.
"There was the odd individual error or poor decision or whatever, but I have to be very careful that I don't get too frustrated when we have actually put in a full, committed performance."
Harlequins director of rugby Conor O'Shea:
"I know what I want us to do. Our peak, our mountain is May 31. I don't know if we'll get there but we'll give it one heck of a shot. The bit is between these guys' teeth and you could see that.
"We knew that we never had room for a slip-up and that adds pressure. The belief within this group has shone through. They just never say die. They played to the bitter end and I just can't give them enough credit. We were 23-5 down and showed the fortitude to come back.
"It has felt like play-offs for us over the past number of weeks in the Premiership. We played magnificent rugby against Sale, we played an incredible match against Leicester and came out on top in that too."
Exeter: Dollman; Vainikolo, Whitten, Hill, Jess; Steenson, Lewis; Rimmer, Cowan-Dickie, Tui; Mumm (capt), Welch; Ewers, White, Horstmann.
Replacements: Scaysbrook for Ewers (24), Yeandle for Cowan-Dickie (60), Brown for Tui (60), Thomas for Lewis (60), Mitchell for Rimmer (68), Slade for Hill (68), Phillips for White (71), James for Whitten (73).
Sin Bin: Welch (52).
Harlequins: Lindsay-Hague; Williams, Molenaar, Turner-Hall, Monye; Evans, Care; Marler, Ward, Sinckler, Matthews, Kennedy, Wallace, Robshaw, Easter.
Replacements: Fa'asavalu for Wallace (61), Guest for Kennedy (62), Chisholm for Williams (72), Dickson for Care (79).
Not Used: Buchanan, Lambert, Doran-Jones, Botica.
Referee: Andrew Small (RFU).