Trump - who lost last year's final 17-14 to John Higgins - seemed set for a place in the quarter-finals when he picked up three of the opening five frames of the closing session to move 12-9 clear having resumed 9-7 ahead overnight against the 2008 finalist.
A break of 59 handed the Bristol youngster a 10-7 lead before Carter compiled 70 to remain within two frames at 10-8 adrift. Trump was on course for a 147 in the 19th frame only to run out of position on the final three reds, but a 96 was ample consolation for an 11-8 lead.
Carter continued to fight the good fight with a 94 in the 20th frame enough to see the pair head for the mid-session interval with Trump 11-9 clear.
A 53 from Trump in the 21st frame made it 12-9, but little did the UK champion know that it would be the last frame he would win at this year's tournament.
Carter made 81 in frame 22 before scrambling over the line to trail 12-11 with a couple of modest efforts in the 30s as his fellow Englishman suddenly looked rattled.
A 53 helped Carter force the deciding frame. With Trump clearly feeling the tension in missing seemingly mandatory pots and looking close to tears in his chair, Carter pounced to make a priceless 47 after his opponent had missed a simple red with a rest.
The drama was not yet over as Carter punched the air to celebrate his win only for Trump to get three of the four snookers he required, but he could not quite achieve the fourth snooker as Carter composed himself to slot the final red to extinguish Trump's hopes for this year.
"I've got a lot of experience. I shouldn't have done the fist-pump, but I thought I was home and dry," said Carter.
"I played a bad shot on the last red. If I had concentrated on getting a good safety, I would have won easy, but it makes it all more sweeter as I had to suffer even more."
Carter's reward is a match with Jamie Jones or Andrew Higginson in the last eight. He will start a warm favourite to progress to the last four.
Judd Trump won six frames in the second session of his World Championship last-16 encounter with Ali Carter to lead 9-7 at the Crucible.
Favourite Trump, the runner-up this time last year, began the afternoon session with a bang and halved the 5-3 deficit carried over from the previous day's action with a rousing 120 break.
The Bristolian would square the match at five frames each after Carter missed frame ball on the final pink, and after the 2008 finalist moved back ahead with a century of his own to the tune of 112 Trump took control with a three-frame rally.
Runs of 43, 80 and 60 highlighted a clear shift in momentum towards the 22-year-old, and though a half-ton from Carter (54) pulled one back in the 15th frame, 'The Ace' rocked a 64 to win the session by four frames and take Carter's own two-frame cushion from him.
Carter and Trump play to a finish on Monday afternoon at 1pm.
Ali Carter leads Judd Trump 5-3 after the opening session of their World Championship last-16 encounter at the Crucible.
Aided by some uncharacteristic unforced errors from Trump, Carter looked the more composed of the players as he won the final three frames of the evening
A missed black off its spot from Trump let Carter in first in the opening frame and another regulation missed brown allowed Carter a second bite of the cherry to establish an early advantage.
Trump got the better of a lengthy safety exchange in frame two to build an early lead but Carter rallied well after another long bout of safety, a 48 break edging him further ahead.
An opening break of 45 put Trump on the way in frame three and another break of over fifty in the fourth meant that the pair headed for the mid-session interval all square at two frames apiece, Carter failing to find the snooker he required to force an unlikely tie with 67 remaining.
Carter looked to have the better of a tight early safety exchange in frame five but Trump knocked in a cracking opening red to set him on the way to a frame winning 62 break.
A mishit opening trump safety let Carter in first in the next, a composed 72 break under pressure pulling the match level at 3-3. Carter was in first with a 46 in frame seven and came out on top of a safety exchange to knock in another 43 break go 4-3 ahead.
Carter was in first with a 39 in the final frame of the evening and another unforced error from Trump let him in again. Despite a seemingly comfortable 54 point advantage, Carter couldn't find position off some incredible reds and Trump looked to have knocked in an amazing clearance on the colours to win it.
But he missed the pink, and despite fluking the snooker, Carter escaped and made the most of his next chance to take the frame.