Nagib Mahfuz, Egypt's most celebrated author and the only Arab to win the Nobel prize for literature, died on Wednesday at the age of 94, several weeks after his health abruptly deteriorated.
"(Mahfuz) suffered a cardiac arrest Tuesday at 7:00 pm but doctors resuscitated him. He had another one today at 8:00 am and this time there was failure," a close friend told the agency.
He was first admitted to hospital in mid-July suffering from various kidney problems, pneumonia and other ailments related to his age.
He was taken to intensive care on August 14 and had remained in critical condition ever since despite improving slightly in recent days.
Security sources said the author would be given a military funeral although the date has not yet been set.
"He was the last of the pioneers," Mahfuz's friend and biographer Raymond Stock told the agency. "He was the only Egyptian who perfectly blended the East and the West."
Born in Cairo in December 1911, Mahfuz was Egypt's most renowned intellectual with about 50 novels to his name. He began writing at the age of 17 and had his first novel published in 1939.
A flurry of other novels followed but it was the Cairo trilogy -- Between the Palaces, Palace of Longing and Sugarhouse -- published between 1955 and 1957, that brought his name to the forefront of Arab literature.
The books, depicting traditional urban life, tell of a family living through the first half of the century when Egypt went from British colonial rule to independence under a monarchy.
In 1988, Mahfuz became the first Arab writer to be awarded the Nobel prize for literature, notably for the universal character of his art, which was considered a metaphor for relations between people in communities worldwide.
"Many classified him as a 19th century-style novelist after the trilogy but in my opinion he surpassed many of the greats from the West," Stock said.
"Although his physical condition deteriorated, his mental powers grew, his literary powers also continued to grow. He learned how to write entire novels in one paragraph."
Nearly half of Mahfuz's novels have been made into films, which have circulated throughout the Arabic-speaking world. He wrote more than 100 short stories, many of which have been translated into English.
A lover of Cairo's sprawling cafes, many of his works centre around life in the bustling city, bringing out its uniquely "Egyptian" character at a key historical period during which a national identity was being defined.
"Mahfuz treated people like an Egyptian and time like a German. He lived a very regimented and disciplined life," Stock said.
Until a few weeks before his death, the writer's frail figure could still occasionally be seen at his favourite Cairo cafes among one of his many circles of friends.
Throughout his life, the author was actively interested in politics, staunchly defending a spirit of tolerance and acceptance, a stance, which brought controversy into his life.
His novel, Children of Gebalawi, published in 1959, was banned by Egypt's Islamic Al-Azhar University for the disillusioned view it gave of religion.
The book brought more trouble for him in the 1980s, when the fundamentalist Jihad group said Mahfuz should be killed for blasphemy over the book.
The author narrowly escaped an assassination attempt in 1994 when a radical Islamist stabbed him with a knife.
In a biography put out when he was named Nobel laureate, the Nobel Foundation said his second period of writing, starting with Children of Gebalawi, saw a "new vein that frequently concealed political judgements under allegory and symbolism."