Mohamed Salah scored the equalizer and created the winner to inspire Egypt's comeback on Sunday to beat Morocco 2-1 after extra time and reach the African Cup semifinals.

Egypt fell behind to an early penalty won by Achraf Hakimi and converted by Sofiane Boufal in the seventh minute.

More Images
Morocco's Adam Masina, right, vies for the ball with Egypt's Mohamed Salah, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Mohamed Salah scored the equalizer and created the winner to inspire Egypt's comeback on Sunday to beat Morocco 2-1 after extra time and reach the African Cup semifinals.

A fan watches players warm up for the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt was left to rely on third-choice goalkeeper Mohamed Sobhy for most of extra time after an injury to Mohamed Abou Gabal, who was already in the team in place of first choice Mohamed el-Shenawy.

Morocco players celebrate a goal during the African Cup of Nations 2022 quarterfinal soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

More AP soccer: https://apnews.com/hub/soccer and https://twitter.com/AP_Sports

Egypt's Ayman Ashraf, left, challenges Morocco's Aymen Barkok, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt's Ayman Ashraf, left, challenges Morocco's Aymen Barkok, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco's Sofiane Boufal, celebrates after scoring after a penalty against Egypt, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)

Morocco's Sofiane Boufal, celebrates after scoring after a penalty against Egypt, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)

Egypt's Mohamed Salah, left, runs as referee Maguette Ndiaye of Senegal, signals a corner kick, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt's Mohamed Salah, left, runs as referee Maguette Ndiaye of Senegal, signals a corner kick, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Referee Maguette Ndiaye of Senegal, left, shows a yellow cart to Morocco's Selim Amallah during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Referee Maguette Ndiaye of Senegal, left, shows a yellow cart to Morocco's Selim Amallah during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco's Selim Amallah, right, tackles Egypt's Omar Marmoush during the African Cup of Nations 2022 quarterfinal soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco's Selim Amallah, right, tackles Egypt's Omar Marmoush during the African Cup of Nations 2022 quarterfinal soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt's Mohamed Salah, and teammates celebrate after he scored a goal against Morocco, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)

Egypt's Mohamed Salah, and teammates celebrate after he scored a goal against Morocco, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)

Salah reacted to knock in a rebound to make it 1-1 in the 53rd and sent in a perfect low cross for Trézéguet to tap in near the end of the first half of extra time.

Morocco's Adam Masina, right, vies for the ball with Egypt's Mohamed Salah, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco's Adam Masina, right, vies for the ball with Egypt's Mohamed Salah, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt was left to rely on third-choice goalkeeper Mohamed Sobhy for most of extra time after an injury to Mohamed Abou Gabal, who was already in the team in place of first choice Mohamed el-Shenawy.

Egypt went through to a semifinal against host Cameroon, which is a repeat of the 2017 final that was won by Cameroon.

Egypt hasn't won the African Cup since its record-extending seventh title in 2010. Salah made his debut for the national team the year after that triumph and is still searching for a first major title with his country.

A fan watches players warm up for the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

A fan watches players warm up for the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

More AP soccer: https://apnews.com/hub/soccer and https://twitter.com/AP_Sports

Morocco players celebrate a goal during the African Cup of Nations 2022 quarterfinal soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco players celebrate a goal during the African Cup of Nations 2022 quarterfinal soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt's Ayman Ashraf, left, challenges Morocco's Aymen Barkok, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt's Ayman Ashraf, left, challenges Morocco's Aymen Barkok, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco's Sofiane Boufal, celebrates after scoring after a penalty against Egypt, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)

Morocco's Sofiane Boufal, celebrates after scoring after a penalty against Egypt, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)

Egypt's Mohamed Salah, left, runs as referee Maguette Ndiaye of Senegal, signals a corner kick, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt's Mohamed Salah, left, runs as referee Maguette Ndiaye of Senegal, signals a corner kick, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Referee Maguette Ndiaye of Senegal, left, shows a yellow cart to Morocco's Selim Amallah during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Referee Maguette Ndiaye of Senegal, left, shows a yellow cart to Morocco's Selim Amallah during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco's Selim Amallah, right, tackles Egypt's Omar Marmoush during the African Cup of Nations 2022 quarterfinal soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Morocco's Selim Amallah, right, tackles Egypt's Omar Marmoush during the African Cup of Nations 2022 quarterfinal soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoThemba Hadebe)

Egypt's Mohamed Salah, and teammates celebrate after he scored a goal against Morocco, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)

Egypt's Mohamed Salah, and teammates celebrate after he scored a goal against Morocco, during the African Cup of Nations 2022 quarter-final soccer match between Egypt and Morocco at the Ahmadou Ahidjo stadium in Yaounde, Cameroon, Sunday, Jan. 30, 2022. (AP PhotoSunday Alamba)