Legia Warsaw joined PSV Eindhoven in the knockout stages of the Europa League thanks to a 3-1 win over Rapid Bucharest.
Rapid were reduced to 10 men after just 25 minutes, but it took the home side until the 53rd minute to open the scoring through Michal Zyro.
The visitors refused to throw in the towel and were back on level terms 11 minutes later, but Legia quickly regained the lead and sealed the win in the final minute, despite having also been reduced to 10 men.
Rapid certainly contributed to their own downfall with Dan Alexa booked after 13 minutes for dissent and then collecting a second yellow card 10 minutes later for a bad foul on Zyro.
Alexa's team-mates defended well enough to see them through to half-time without conceding, with Legia failing to take full advantage of their numerical superiority.
However, the hosts finally got their act together eight minutes into the second half when Maciej Rybus's cross was turned into the bottom corner by Zyro from 12 yards out.
If the home fans in the 42,000-strong crowd thought that would signal an easy evening for their side, they were in for a shock when Rapid hit back on 64 minutes.
Ovidiu Herea's pass found Teixeira in a little bit of space in the penalty area and he confidently fired past goalkeeper Dusan Kuciak to level the scores.
However, Legia were quick to respond and restored their lead four minutes later when Miroslav Radovic drilled home a right-footed shot from 12 yards.
The home fans were still celebrating when their side was reduced to 10 men moments later, Janusz Gol picking up his second booking in the space of 10 minutes to join Alexa back in the dressing rooms.
But it ultimately did not prove costly for Legia, who secured all three points in the closing moments when Michal Kucharczyk slotted home the third from Rafal Wolski's pass.