Senegal, Ivory Coast through to last 16 at African Cup
Mane netted in the 71st minute and got it right with his second penalty of the game in the 78th as Senegal beat Kenya 3-0 to take second in Group C and make the last 16.
Ismaila Sarr scored the first for Senegal in the 63rd, burying a volley in the top left corner as the team rated as a contender for the title took over an hour to break down Kenya in its must-win final group game at 30 June Stadium in Cairo.
Algeria, which had already qualified, won the group with a 3-0 win over Tanzania.
Ivory Coast also progressed on Monday.
Mane looked for the bottom left corner with his first-half penalty against Kenya but it was weak and goalkeeper Patrick Matasi saved.
Matasi was to blame for Senegal's opening goal, though. He rushed out to punch away a cross and missed and Sarr, with his back to goal, hooked a volley in to give the West Africans the lead.
Mane's first came on a quick break when he chased a long pass, muscled his way past two Kenyan defenders and slipped a shot past Matasi from the edge of the area.
Kenya defender Philemon Otieno was given a second yellow card and sent off for ramming his studs into the shin of Sarr to give Senegal a second penalty.
Mane opted for the bottom right corner this time and he beat Matasi's dive.
Mane matched Liverpool teammate Mohamed Salah of Egypt with two goals in the group stage of the tournament.
Ivory Coast, the 2015 African champion, led Namibia 2-0 through goals by Max Gradel and Serey Die. Joslin Kamatuka took advantage of a miscued clearance by Ivory Coast goalkeeper Sylvain Gbohouo to make it 2-1 with just under 20 minutes to go.
But the Ivorians scored twice more in the last six minutes with slick finishes by Wilfried Zaha and Maxwel Cornet.
South Africa paid for its conservative approach against Morocco, as the South Africans appeared to be playing for a draw.
The plan backfired when Morocco captain M'Bark Boussoufa scored the only goal in the 90th minute. He was the first to react to a loose ball in the South Africa area and poked home his shot to settle the game right at the end.
Morocco finished the group stage with three wins from three games, all of them by 1-0. Algeria also won three from three to finish above Senegal.
The fates of Kenya and South Africa hang in the balance and they will have to wait until the group stage wraps up on Tuesday to see if they are among the four best third-placed teams to get a spot in the round of 16.
Host Egypt, defending champion Cameroon and tournament surprise package Madagascar, which is playing at its first African Cup, are among the teams to have already made the last 16.