Heart of the Night consists almost entirely of a tale told in a single night, as Jaafar Ibrahim Sayyid al-Rawi relates how he came to be in the sorry position he is, near destitute and alone, living in the ruins of his grandfather's house.
There is a separate narrator, the man to whom Jaafar tells the story, and the first two, brief chapters introduce these two characters and explain how Jaafar comes to relate his story; the narrator also occasionally interrupts Jaafar's accounts, with questions or comments, but the narrative consists predominantly of Jaafar's life-story as he tells it.
Jaafar met the narrator because Jaafar wants to demand his rights, specifically to his grandfather's estate.
As the narrator explains, however, since the al-Rawi estate became a charitable waqf (i.e. the estate was given over to charitable purposes) Jaafar has no claim to it.
Jaafar is angry about how unfair this is, and he relates his life story to explain how unfairly he's been treated -- though as it turns out he did a few things that make it quite understandable why the old man cut him out of the will.
Losing his parents when he was very young, Jaafar was sent to live with his wealthy grandfather.
This actually worked out quite well.
While a devout old man, who had been estranged from Jaafar's father and also recently lost his own wife, al-Rawi got on well with the boy and was happy to support his studious ways, noting:

What counts for me are your pure will, your faith, and your love of religion.

Of course, eventually Jafaar strayed from the path, felled by love.
As bad luck would have it, the girl who catches his eye and completely bewitches him is a gypsy shepherdess from the worst part of town.
But once he has his heart set on Marwana there's nothing to be done: "No matter what, I must have her."
They marry and, of course, al-Rawi disowns his grandchild.
Unfortunately, the love of Jaafar's life also turns out to be a rather fleeting passion.
He isn't nearly enough man for her, and:

Marwana was only a sexual provocation; not a housewife, a mother, or a woman in the true sense of the world.

Surprisingly, Jaafar finds love -- and a far more comfortable life -- again, when an older woman falls in love with him.
Although Huda Sadeeq is ten years his senior, he sees this as an opportunity not to be missed, and professes his love.
They get married and live quite happily -- though there is no reconciliation with al-Rawi.
At Huda's urging and with her support, Jaafar completes his education -- but he also becomes interested in politics.
He claims: "I am a diligent student who worships the mind", but politics proves dangerous, and Jaafar can't quite control his impulses and emotions, and he ruins everything again.
Now, years later, all he has is his sorry tale to relate, having lost everything.
Jaafar is an arresting figure and narrator, filled with self-pity and stubborn pride.
Early on he tells the narrator that he wants to press his case to get his grandfather's estate, regardless of how improbable success is:

I will provoke a revolution that will reverse the order of the universe.

In fact, however, the fates buffet him around (though it is his impulses -- his unwillingness to step back and make a rational decision at pivotal moments -- that are his downfall).
By now, in old age, his self-delusion is particularly blinding -- he notes, for example, the similarities between his own life and that of the Prophet -- though clearly it is that he is torn in so many directions that undermines him: he can never rid himself of his religious allegiance, even as he distances himself from his grandfather's sort of piety -- hence also comparisons to the Prophet and the like -- and while a would-be intellectual -- he does worship the mind -- he also drifts easily into the indulgences of wine, women, and song (though he's actually not much of a womanizer).
Of course, Jaafar tells his own story, and thus is able to present himself almost entirely how he wishes (or sees himself).
And he goes so far as to suggest -- before he actually gets down to telling his story -- that:

There is no 'truth and fiction,' but different kinds of truths that vary depending on the phases of life and the quality of the system that helps us become aware of them.
Legends are truths like the truths of nature, mathematics, and history.
Each one has its spiritual system.

Indeed, what perhaps determined (and destroyed) Jaafar's life was that he could never depend entirely on a single system, and without that hold he found his worlds upended, time after time (though he did contribute mightily in some cases).
At just a hundred pages, Heart of the Night is more a longer story than a full-fledged novel.
Too much is rushed through, especially about his later life -- all the more noticeably because when Mahfouz allows the narrative to linger over specific episodes the story blossoms.
There are some very fine and evocative scenes here, especially when Jaafar speaks of his childhood; if the same in-more-depth treatment had been applied more consistently Heart of the Night could well have been quite remarkable.
The rush -- and especially the speed with which some of the significant turning-points are addressed -- weaken the work; not fatally, but significantly.
Nevertheless, Jaafar is an irritatingly fascinating figure and narrator throughout (and his interlocutor, if not quite involved enough, a good and often humorous counterpart), and his story is strong enough, even in this occasionally abbreviated form.
Heart of the Night is a good little novel, and a modest success.