There were a few nerves at the end but Liverpool set up a Champions League semifinal with Spain's Villarreal after Roberto Firmino scored twice in a 3-3 second-leg draw with Benfica on Wednesday to ensure a 6-4 aggregate win.

Juergen Klopp's side had been 3-1 up on the night before the visitors struck twice late in the game to create a jittery finale to what had appeared to be a comfortable passage.

The Lisbon side exited the competition with the applause of its own fans - and Liverpool's - ringing in their ears after delivering a performance full of belief and commitment until the end.

With a 3-1 lead from the first leg in Lisbon, Liverpool manager Klopp made seven changes to the team which drew with Manchester City at the weekend, but his squad showed their improved strength in depth with Luis Diaz and Kostas Tsimikas particularly impressing.

AS IT HAPPENED | Champions League Highlights: Liverpool qualifies for semis with aggregate score of 6-4; match finishes 3-3

Benfica forward Darwin Nunez had seen an effort ruled out for offside before Liverpool took the lead with a powerful header from a corner by defender Ibrahima Konate in the 21st minute.

Konate, who had also scored in the first leg, rose well to meet Tsimikas's corner and give Liverpool a three-goal cushion.

The lead on the night lasted just 11 minutes though before Benfica pulled level through Goncalo Ramos, who beat Alisson Becker after a tackle from James Milner had fallen to him on the edge of the box.

Brazilian Firmino scored twice after the break as Liverpool looked to make sure of a place in the semifinals for the third time in five seasons.

He made it 2-1 in the 55th minute after Benfica keeper Odysseas Vlachodimos spilled the ball out, his defenders could not clear their lines and Diogo Jota's slightly mis-hit cross was turned in by the Brazilian at the back post.

Firmino's second goal was a more elegant affair - Tsimikas floating a free-kick over the Benfica defence for the striker to beat Vlachodimos with a side-footed volley.

READ | Champions League: Man City holds off frustrated Atletico Madrid to reach semifinals  

But Benfica stuck at the task well and pulled two goals back in the latter stages to return a degree of tension to Anfield.

Substitute Roman Yaremchuk made it 3-2, the Ukrainian forward latching on to a through ball from Alejandro Grimaldo and rounding Alisson before sliding his finish into the empty net.

The goal was initially flagged for offside but allowed after a video review.

It was a similar story for their equaliser on the night - with Nunez's effort, after Benfica sprung Liverpool's offside trap, also ruled out before the intervention from VAR.

The impressive Nunez had an effort disallowed in stoppage time but this time VAR backed the on-field call and Liverpool could evade what might have been a scary final few minutes.

Liverpool's thoughts will now turn to its FA Cup semi-final with Premier League title rival Manchester City at Wembley on Saturday.

But for Benfica, it was an honourable exit from the tournament as its fans recognised it with long and loud appreciation after the final whistle.