Mohamed Salah blasted home a free-kick to give Egypt a 1-0 win over Ghana and top place in Africa Cup of Nations Group D as the quarter-final lineup was completed on Wednesday.

Salah’s rasping 10th-minute strike sent Egypt to the top of the table with seven points and Ghana, who won their first two games, finished second on six.

Egypt will now play Morocco in the quarter-finals in Port Gentil on Sunday while Ghana travel to Oyem to face the Democratic Republic of Congo on the same day.

Egypt were awarded a free-kick after a clumsy challenge by John Boye on Abdallah El Said and Salah stepped up to hammer the ball through the wall and leave Ghana goalkeeper Razak Brimah with no chance.

The seven-times African champions might have had a two-goal advantage at half-time after Brimah’s sloppy clearance went straight to Marwaan Mohsen but with the goalkeeper caught out of position the Egypt striker sent his shot on to the roof of the net.

Stout defending kept Ghana at bay in the second half with 44-year-old goalkeeper Essam El Hadary doing well to deny Christian Atsu’s powerful strike and another from Jordan Ayew one minute from time.

It was the third successive clean sheet for Egypt who are playing in the tournament in Gabon after a seven-year absence.

Ghana will be concerned about a suspected groin injury picked up by captain Asamoah Gyan in the first half which forced him off the field. They have already lost first-choice left back Baba Rahman to a serious knee injury as the poor pitch at the newly-built stadium in Port Gentil has taken its toll.

Uganda, meanwhile, scored their first goal at an Africa Cup of Nations finals for 39 years as they bowed out of the tournament with a 1-1 draw against Mali on a sodden pitch on Wednesday.

Uganda, who last played at the tournament in 1978, had already been eliminated before kick-off and the stalemate ended Mali’s hopes of progressing from Group D as Egypt and Ghana both went through.

Neither side had scored in their opening two games and the game produced 70 minutes of dismal football on a shocking surface before suddenly coming to life with two spectacular long-range goals within four minutes.

Uganda took a deserved lead when Farouk Miya collected ball just outside the area and fired a rising shot into the top corner.

Mali, five-times semi-finalists and once runners-up, quickly replied when 20-year-old Yves Bissouma scored with an even more impressive effort, a 30-yard free-kick which flew into the net and left Robert Odongkara rooted to the spot.

The match, played in front of a sparse crowd which has become an unfortunate feature of the tournament, was preceded by a tropical downpour which left large parts of the pitch at the newly-built Stade d’Oyem under water.

Uganda’s defender Godfrey Walusimbi challenges Mali’s midfielder Yves Bissouma in Oyem. Photograph: Issouf Sanogo/AFP/Getty Images

The pitch deprived Uganda of their best first-half chance when Luwagga Kizito ran onto a through ball and got clear of the Mali defence, only for the ball to get stuck in pool of water before he could shoot.

Mali’s best first-half effort was a Yacouba Sylla shot which he curled over the bar from just outside area as the players continued to splash around.

Uganda adapted better to the conditions in the second half and had a goal disallowed when Iceland-based Tony Mawejje’s shot took a deflection off Kizito who was in an offside position.

That was followed by four minutes of excitement with the two goals before normal service was resumed and the scrappy encounter ended in a draw.

Africa Cup of Nations quarter-final lineup

Sat 28 Jan: Burkina Faso v Tunisia (Libreville), Senegal v Cameroon (Franceville). Sun 29 Jan: Egypt v Morocco (Port Gentil); Ghana v DR Congo (Oyem)