Husni Mubarak, the Egyptian president, walked behind Mafhouz's flag-draped coffin as it was led through the streets of the capital to the sound of drums and trumpets.
Mahfouz, the only Arab to have won a Nobel prize for literature, died on Wednesday at the age of 94.
Fans of the writer waited in the scorching Cairo sun for hours, only to be told by security officials that they would not be allowed to attend the procession.
One Mahfouz fan named Amal shouted: "He doesn't want a state funeral...he wants the people to bear him on their shoulders.
"Did he write for the flag? Did he write for the horses? He wrote for the poor. We should walk in his funeral."
In keeping with Mahfouz's wishes, a small ceremony had been held earlier in the day in the Al-Hussein mosque, in the heart of historic Cairo where many of his novels were set.
A witness said a small group of men had attempted to enter the mosque in protest at prayers for Mafhouz being held there, as they said he was an infidel.
In 1988, he survived an assassination attempt when he was stabbed in the neck by radical Islamists.
Religious authorities said his novels broke Islamic rules by depicting God and prophets.
After the state funeral, Mahfouz was buried in a cemetery on the outskirts of Cairo.