Paris St-Germain had to settle for second place in Group H after a late sixth goal at Maccabi Haifa.
In the other game, they thought they had finished the group with a win.
The clubs' head-to-head record, goal difference and goals scored were all tied at one point.
The away goals in all group games separated them.
There was a goal and a penalty in the first half as Benfica went in at the break with a one-point lead.
After Petar Musa's 59th-minute goal sent them on their way, Alex Grimaldo and Rafa Silva netted before Henrique Araujo put them within touching distance.
Mario scored from 25 yards to seal the win.
The top two teams in a group have the same amount of wins, draws, defeats, points and goals.
"We were worried about winning, as always, then we felt that it was possible to reach first place and we went looking for more goals."
We saw that it was within our grasp as the game went on. I was happy to help the team with a goal.
Nuno Mendes' second-half winner for Paris Saint-Germain was enough to give them the top spot.
Kylian Mbappe gave the French club the lead with a solo opener.
The coach of Paris Saint-Germain said: "First of all, I would like to wish Benfica a happy birthday." I have to acknowledge my squad as well.
We were very happy until the 92nd minute, when we lost to them. You have to beat big teams to go far in this competition. We'll see who we get in the round of 16 when the draw is made.
Out of Europe, Maccabi is out of theEuropa League.