Knowing only victory would be enough to see them finish second in Group B, Liverpool started slowly at Anfield and fell behind when Fabian Frei fired into the bottom corner after 25 minutes.
The hosts’ task was made even harder when half-time substitute Lazar Markovic was harshly sent off on the hour mark for catching Behrang Safari in the face with his hand.
But Gerrard gave Liverpool a lifeline with 10 minutes to go when he curled in a fine free-kick off the post.
The goal sparked the Reds into life and they threw everything at Basel in the closing stages, with Jordan Henderson twice going close to scoring.
However, there were no late Champions League heroics as Basel held on to book their place in the last 16 and relegate Liverpool to the Europa League.
While the Reds may feel slightly aggrieved following Markovic’s dismissal and their late spell of pressure, they ultimately paid the price for a sluggish start and for only taking four points from their previous five group games.
Having made four changes to the starting line-up, bringing in Gerrard, Jose Enrique, Joe Allen and Dejan Lovren, Brendan Rodgers would have been disappointed as his team’s early performance on the pitch did not match the electric atmosphere off it.
The hosts looked shaky at the back from the first minute and it didn’t take Basel long to threaten as Luca Zuffi played in a pass for Shkelzen Gashi, who failed to hit the target from a promising position just outside the area.
Liverpool’s best moments of the first half came from Raheem Sterling, who passed up a good opportunity when he tried to find Gerrard instead of going for goal himself.
Still, Basel looked the better team and moments after Marco Streller saw a close-range shot blocked, the visitors took the lead when Frei drilled a fine shot across goal and into the far corner.
It could have been even worse for Liverpool as they struggled to cope with Basel’s pace. Enrique just managed to dispossess Derlis Gonzalez as he was about to pull the trigger before Streller failed to hit the target with a volley after being left wide open at the back post.
Glen Johnson almost provided a chance late in the half but his cross from the right flew over the head of Lambert.
That was to be the last sight of Lambert as he was replaced at the break by Markovic, with Enrique also coming off for Alberto Moreno.
The introduction of Markovic looked as though it might provide the spark Liverpool desperately needed as he ran at defenders and tested the Basel rearguard.
But his time on the pitch was cut short when he was shown a straight red card on the hour mark for catching Safari in the face with his hand. While it was unnecessary, and silly, for Markovic to swing his hand towards Safari as he ran with the ball, there was minimal contact made and it looked a harsh decision by referee Bjorn Kuipers.
The dismissal left Liverpool with a mountain to climb and the game appeared to be heading towards a tame ending until Gerrard’s superb free-kick breathed new life into it. The unstoppable strike was the 100th he has scored at Anfield and set up a thrilling finish.
Needing just another goal to progress at the expense of their opponents, Liverpool looked a different side as they piled on the pressure in the final 10 minutes.
They came agonisingly close to snatching victory when Tomas Vaclik saved on the line after Henderson’s deflected header looked to be heading in.
Sterling then almost got on the end of a Gerrard through ball before Henderson had a shot from range well saved by the ‘keeper.
Basel also had chances as the game opened up but in the end they didn’t need another goal as a draw secured their progress to the last 16.
Phil Thompson’s verdict
“It’s very difficult to see why Markovic came on when you’ve seen Lallana playing in most of the games. Coutinho, you would think, has a lot more to open up this defence. So I thought that was very, very strange. You just wonder how and why they weren’t playing.
I’d like to see certain players like Adam Lallana given a run. He’s been the one that you could say has done very, very well. But he’s in for one match, he’s man of the match, then he’s out for two games. You think ‘what’s going on on the training ground?’”
Liverpool: Mignolet (6), Johnson (6), Lovren (5), Skrtel (6), Jose Enrique (5), Allen (6), Lucas (5), Gerrard (7), Henderson (6), Sterling (6), Lambert (5).
Subs: Coutinho (6), Moreno (5), Markovic (5).
Basel: Vaclik (7), Schar (6), Suchy (6), Safari (5), Xhaka (7), El-Nenny (5), Frei (7), Gashi (6), Zuffi (7), Streller (6), Gonzalez (6).
Subs: Samuel (6), Diaz (6), Embolo (6).
Man of the match: Fabian Frei.