But with time running out, MohamedSalah was tripped inside the box, allowing Mohamed Abou Trika to score from the penalty spot with just two minutes left.
MohamedSalah increased the pressure on Brazil, who are seeking to win their first Olympic football gold medal, with his goal 14 minutes from the end, but Egypt couldn't find an equalizer.
Rafael, Leandro Damiao and Neymar each scored in a blistering opening to the match, but second-half goals from Mohamed Aboutrika and MohamedSalah meant yet another medal contender had to endure an anxious finale.