The commission said Morsi won with 51.7 percent of the vote versus 48.3 for Shafiq.
A huge crowd of Morsi supporters in Cairo's Tahrir Square erupted in cheers when the results were announced on live television.
The results put an end to the country's nerve-wracking uncertainty about who was the official winner, but it promises no resolution to the power struggles between Islamists, the military and other factions. It's still unclear exactly how much power the new president will actually have.
The Associated Press contributed to this report.