Rafael opened the scoring in the 16th minute, Leandro Damiao added another in the 26th and Neymar scored in the 30th to give Brazil a comfortable halftime lead before Egypt made it interesting with goals by captain Mohamed Aboutrika in the 52nd and substitute Mohamed Salah in the 76th.
Brazil was able to control the rest of the game and held on for the victory, staying on track for its first gold in Olympic football. The team leads Group C with three points along with Belarus, which beat New Zealand 1-0 in Coventry.
The Olympic tournament is the only significant football competition Brazil has never won. The country's senior side is a five-time world champion. Brazil finished with Olympic silver in 1984 and 1988 and the bronze in 1996 and 2008.
Brazil is one of the few teams with many of its top players in the Olympic tournament and has been touted as one of the main favourites for the gold. There are high expectations as several of the players in the Olympic squad will also likely be in the team trying to win the World Cup at home in 2014.
Egypt entered the competition trying to restore some of its football pride nearly six months after a stadium riot that killed more than 70 people and forced the suspension of the national league.
"We got what we needed in the opening match, and that was the victory," Brazil coach Mano Menezes said. "We built our result with a very good performance in the first half but we couldn't repeat it in the second, in part because Egypt improved and in part because of our own mistakes."
Manchester United right back Rafael scored the first goal after a perfect through ball by newly signed Chelsea playmaker Oscar. Rafael cleared a defender with one touch and fired a low left-footed shot into the net.
"We showed our quality in the first half," Rafael said. "We weren't able to keep playing as well but in the end it was a good result."
Oscar set up the second goal too, beating a defender and the goalkeeper to a long ball lobbed into the area and sending a pass back toward Damiao, whose shot easily got past the lone Egyptian defender on the line.
"We got off on the right foot," Oscar said. "The first match is always hard but we have to be proud of what we did in the first half."
Neymar, seen as Brazil's future star, added to the lead after finding Hulk open on the left side of the area. The FC Porto forward crossed the ball back and Neymar headed it in from close range.
Egypt pulled one back when Meteab Emad hit the post and Aboutrika scored off the rebound. Salah got the Egyptians even closer after the defenders failed to clear a ball inside the area and allowed him to shoot into the left corner.
"If we hadn't made the mistakes in the first half maybe we could've had a better result at the end, but that's football, we will have to learn from it," Egypt coach Hany Ramzy said. "I'm proud of my team, especially in the second half."
The match was played in front of nearly 27,000 mostly pro-Brazil fans at the Millennium stadium in Cardiff, Wales.
Brazil will play its second match against Belarus on Sunday while Egypt will face New Zealand the same day.
Follow Tales Azzoni at http://twitter.com/tazzoniSuggest a correction