Liverpool 1-1 Hearts (2-1)
A Luis Suarez strike two minutes from time squeezed Liverpool into the group stage of the Europa League.
Hearts had led for three minutes thanks to a David Templeton strike that was spilled into his net by Pepe Reina.
But they could not hold out for extra-time as Suarez eventually notched the goal he had been threatening all match.
Hearts, though, will return to Edinburgh full of pride at their performance over the two legs.
Similar to the first leg, Hearts had plenty of early possession but they were carved open and almost fell behind after 14 minutes.
Jamie Carragher released Stewart Downing down the left and his deep cross was headed back across goal by Steven Gerrard. The lurking Suarez's subsequent header looked goal-bound but Marius Zaliukas got back to sweep the ball off the line.
Despite their status as massive underdogs, Hearts looked composed and a flowing move ended with Mehdi Taouil sending a shot tamely into the arms of Reina.
The visitors then had a decent claim for a penalty turned down when Callum Paterson tumbled under Carragher's challenge before Liverpool began to turn up the heat.
Adam Morgan's powerful effort from 25 yards was spilled by Jamie MacDonald but, with Gerrard bearing down on him, the keeper recovered to dive on the ball.
The Hearts man did even better on the half-hour mark as he rushed off his line to save from Gerrard, who had waltzed through three challenges on his way into the box.
Liverpool thought they had taken the lead shortly afterwards as Morgan tapped into an empty net, only for the assistant referee to indicate Suarez had carried the ball out of play before cutting it back.
Templeton was looking like Hearts' most threatening player, but he should have done better than hit high and wide when the ball dropped kindly for him 25 yards from goal just before the break.
Liverpool started the second half at a high tempo and carved out an early opportunity for Jonjo Shelvey, who rifled the ball just off target from outside the box.
Hearts had defended superbly for the first hour but, as slackness began to creep in, Liverpool threatened to punish them.
Suarez rounded MacDonald after beating the Hearts offside trap but Ryan McGowan did brilliantly to get back and block the shot on the line.
Moments later Arvydas Novikovas lost out to Shelvey, allowing Suarez to turn and shoot, but once again his effort flew just wide, as did a ferociously whipped shot from Gerrard as the match entered the final quarter.
The pace and alertness of Suarez continued to cause problems in the Hearts backline and only evasive action from MacDonald prevented the Uruguayan profiting from another throughball, before the keeper used a leg to deny Gerrard at his near post.
Hearts chances by this stage were few and far between, so when Taouil was wasteful from just outside the box, the groans from the visitors' end were keenly felt.
But that anguish turned to rapturous joy five minutes from time when Templeton's speculative attempt from 25 yards squirmed from the grasp of the embarrassed Reina.
Suarez spared his keeper's blushes, though, when he raced clear three minutes later, evaded the challenge of Zaliukas and beat MacDonald from a narrow angle to send his side into the group stage of the Europa League.
Liverpool manager Brendan Rodgers:
"We achieved the objective which was to get through. They were two very tough games and they were never going to be easy.
"I thought the attitude and commitment of the players was excellent. We showed our spirit towards the end when we went behind. Our spirit really came through.
"I thought we were wasteful. We created chances and could have put the game to bed a lot earlier, but the most important thing was to get through and we have done that."