The Portuguese side were on the brink of elimination from the Champions League before a late strike kept their qualification hopes alive
Olympiakos went into the Group B clash three points ahead of the third-placed Portuguese, but the Greeks' late defeat at Paris Saint-Germain allowed the Eagles to move level with them on points, albeit behind them on the head-to-head record.
Jorge Jesus' men trailed 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. Nicolas 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 counterattack 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 in stoppage-time.
Benfica now await the visit of PSG in their final, decisive group game.