Debutants Tajikistan fight back to reach Asian Cup knockouts
China's 1-0 loss to hosts Qatar meant Tajikistan went through in second place from Group A on a night of drama.
Before the third and final round of games, holders Qatar were the only team to have scored a goal in the group, and any of the other three had a shot at finishing behind them in second.
In a stadium festooned with their cedar-tree flags, Lebanon took control of the game early, launching repeated attacks but finding no more penetration than they had in their previous two games.
Tajikistan were mostly restricted to shots from outside the box until the stroke of half-time, when midfielder Mabatshoev Shervoni slalomed into the Lebanon area, his attempted cross taking a huge deflection off Lebanon's Robert Melki to loop over the wrong-footed goalkeeper and into the net.
But Tajik celebrations were cut short when the referee ruled the goal out for the tightest of offsides.
Their misery was compounded almost immediately after the restart when Bangkok United forward Bassel Jradi arched in a delicious strike from the edge of the area and inside the far post.
But Lebanon soon had a man sent off when a VAR check upgraded Kassem El Zein's yellow card - for a studs-up, over-the-ball tackle - to a red.
With a man advantage, Tajikistan camped out in the opposition half, and as the 70th minute approached they once again thought they had scored.
But Alisher Dzhalilov's goal was scratched off, again for a cruelly slender offside.
When their equaliser did finally arrive, there could be no doubt, Parvizdzhon Umarbaev topping Jradi's strike with a curling free kick to bring stunned silence to the Jassim Bin Hamid Stadium.
As things stood the Tajiks were going through in second, but they continued to push for a winner.
No sooner had the fourth official signalled a whopping 16 minutes of added time, than they got it, substitute Nuriddin Khamrokulov flicking a delicate backwards header over goalkeeper Mostafa Matar.
Lebanon's Hilal El-Helwe had a chance to pull one back, at the death, but shot wide as they exited the tournament.