The Polish striker dragged Xavi Hernandez's side level at 2-2 in the 82nd minute and then again at 3-3 in stoppage time with a towering header, after Robin Gosens put the Italians ahead with one minute remaining.
Barcelona's Champions League fate is no longer in their own hands though and they still face a second consecutive group stage elimination if Inter Milan win at home against eliminated Viktoria Plzen on October 26.
Being on the verge of another early knockout is a bitter blow for the Catalans, who hoped a summer signing spree including Lewandowski from Bayern Munich could restore their position among Europe's elite.
"We had an enormous opportunity and we didn't take it," said Barcelona defender Eric Garcia.
"We made errors that at this level, you cannot make. We fought back and managed to get the draw. We're not out but it's complicated. We have to keep going, while there's still some hope."
The hosts made the early running but Lautaro Martinez flashed a warning shot into the side-netting on the counter attack, with Inter sitting deep but ready to spring forward.
Lewandowski, in search of his first goal in three games, had a header cleared off the line by Henrikh Mkhitaryan and Raphinha's shot was deflected inches over the crossbar.
At the other end Edin Dzeko hit the crossbar, with the ball bouncing down but not crossing the goal-line, with Barcelona gratefully scrambling the ball to safety.
Andre Onana denied Ousmane Dembele and Pedri, while his Barcelona counterpart Marc-Andre ter Stegen produced a solid stop to keep out Denzel Dumfries on the break.
Raphinha was frustrated after skewing a volley wide but his work-rate proved crucial when Barcelona broke the deadlock. The Brazilian winger chased a ball down in the corner and fed Sergi Roberto, who cut the ball across for Dembele to blast home from close range.
It was his first goal in the Champions League for nearly two years, and another milestone in his renaissance under Xavi, arguably Barcelona's best player since the coach arrived at Camp Nou in November 2021. Dembele embraced his coach on the side of pitch after an emphatic celebration.
Inter stewed on the goal at half-time and quickly produced one of their own, netting in the 50th minute after Gerard Pique played Nicolo Barella onside and the Italian rifled home.
The Inter midfielder snuck behind Pique, who waved a cross past him, towards Ter Stegen, not reading Barella's movement.
The defender, 35, was starting his first Champions League game of the season, with Barcelona paying the price for Jules Kounde, Ronald Araujo and Andreas Christensen's injuries.
And it was another of the team's veterans who gave the ball away for Inter's second goal, with Sergio Busquets conceding possession with a stray pass. Hakan Calhanoglu found Martinez, and the Argentine striker left Garcia for dead and slammed home via the post.
Lewandowski drilled past Onana at the other end but was clearly offside, as Barcelona desperation grew, with the Polish forward sending a diving header wide.
Eventually Lewandowski got his goal with a deflected strike at the second attempt after substitute Alejandro Balde found him in the area.
Gosens thought he had handed Inter qualification and eliminated Barca when he struck late on from Martinez's cross, on yet another counter-attack, but Lewandowski had other ideas.
The striker's towering header saved Barcelona from certain elimination, but their future in the competition still hangs by a thread.
There is little time for Barcelona to pick themselves up and dust themselves down. On Sunday, Real Madrid beckon at the Santiago Bernabeu in La Liga.