Benfica kept alive their chances of qualifying for the UEFA Champions League knockout phase as Rodrigo secured a 3-2 win in stoppage time.
Olympiacos went into the Group B clash three points ahead of third-placed Benfica, but the Greeks' late defeat at Paris Saint-Germain allowed the Portuguese side to move level with them.
Jorge Jesus' men trailled to Chancel Mbemba's 18th-minute opener but hit back through Nemanja Matic 11 minutes before the break, with Mbemba's own goal handing the visitors the advantage early in the second half.
Massimo Bruno struck with an excellent finish 14 minutes from time to move Anderlecht level, only for substitute Rodrigo to provide a dramatic twist with a last-gasp winner.
After a quiet start, the first chance fell to Anderlecht in the 17th minute. Aleksandar Mitrovic cut a pass back to the edge of the area for Bruno, but Artur tipped it over the bar.
The goalkeeper could do nothing to prevent his side falling behind a minute later, though.
Fabrice N'Sakala lofted a pass into the area from deep for Mbemba and after his first touch ricocheted back off Luisao, the Congolese defender slotted under Artur.
Mitrovic saw a goal disallowed for offside just before the half-hour mark and Benfica made the most of it four minutes later.
Matic nodded Enzo Perez's left-wing free-kick past Silvio Proto, but Cheikhou Kouyate nearly restored the hosts' lead with the next attack as he headed a cross narrowly over.
Benfica needed only seven minutes to take the lead in the second half. Nico Gaitan latched on to a throughball in the area and after producing a clever turn, he hit a low shot that was deflected in by Mbemba.
After taking the lead, Jesus' side became more inclined to hit Anderlecht on the counter-attack and Lima went close to scoring a third as he stroked a shot just over with the outside of his foot following Perez's cutback.
Bruno grabbed the equaliser from a narrow angle in the 76th minute, but Rodrigo had the last word, applying a cool finish after racing clear.
Benfica now await the visit of PSG in their final, decisive group game.
STATS ZONE Anderlecht 2-3 Benfica analysis