Cairo - Mohamed Salah scored from a free-kick as host nation Egypt defeated Uganda 2-0 in Cairo Sunday to win Group A at the Africa Cup of Nations with a perfect three-win record.
Pre-tournament favourites Egypt will remain in Cairo for the round of 16 and play one of the best four third-place finishers next Saturday.
After prolific Liverpool scorer Salah put Egypt ahead against the run of play on 36 minutes, captain Ahmed Elmohamady added a second just before half-time.
Uganda had plenty of possession in both halves and often threatened to score without managing to put the ball in the net.
Egypt topped the final standings with nine points and Uganda came next with four to also qualify automatically for the knockout phase.
The Democratic Republic of Congo came third with three points after trouncing Zimbabwe 4-0 in another Cairo stadium.
Elmohamady said: "Nine points out of three games is something Egypt is used to - the difficult part is what comes next.
"As of tomorrow, we will start to prepare, regardless of the team we will meet in the last 16.
"We scored five goals in three matches and kept three clean sheets. For me these are good numbers."
Uganda were more impressive than Egypt for the first 30 minutes on a hot night at a packed 75 000-capacity Cairo International Stadium.
Goalkeeper Mohamed Elshenawy did well to push a sizzling, long-range Allan Kyambadde drive over at the expense of a corner.
Abdu Lumala was a constant threat for the Cranes and had a shot and a header saved in quick succession with the Pharaohs defence not its normal assured self.
Salah then turned the tide toward the record seven-time African champions by lifting a free-kick over a defensive wall and past goalkeeper Denis Onyango into the corner of the net.
It was the second goal of the tournament for the Egyptian idol and Elmohamady notched his second in first-half stoppage time.
A low cross eluded two Egyptians, including Salah, but fell to Elmohamady, who unleashed a low shot that took a slight deflection en route to the far corner of the net.
It was a massive blow for the Ugandans, who did not deserve to be two goals behind as they walked to the changerooms.
The pace of Salah gave him a chance to score his second goal soon after the break, but Onyango made a superb one-hand block to foil the 2018 African Footballer of the Year.
Uganda regained their composure to cause constant problems for the home team, but lacked a clinical finisher like Salah.
Earlier, Africa Cup of Nations newcomers Madagascar pulled off a stunning upset of powerhouses Nigeria with a 2-0 win over the three-time former champions to clinch a place in the last 16.
Lalaina Nomenjanahary gave Madagascar a shock 12th-minute lead in Alexandria and Charles Andriamatsinoro sealed the victory.
At the 30 June Stadium in Cairo, the Democratic Republic of Congo put a two-loss start to the tournament behind them with a 4-0 triumph over Zimbabwe, the biggest of the competition so far.
Jonathan Bolingi punished a blunder by goalkeeper Elvis Chipezeze to head the Congolese Leopards in front on four minutes and Cedric Bakambu added a second before half-time.
China-based Bakambu netted again midway through the second half and Britt Assombalonga added a fourth.
The Congolese will know only Tuesday night after the final group matches whether they are among the best four third-place finishers and remain in the competition.