Fidel Castro revealed Thursday he thought he was dying when he fell ill in July 2006, and was so worried about his legacy that he ordered last-minute editing of his memoirs even as doctors struggled to save his life.

"When I fell gravely ill the night of the 26th and dawn of the 27th of July, I thought that would be the end," the ailing 81-year-old wrote in an essay published on the front page of state newspapers.

"And while the doctors fought for my life, the head aide of the Council of State read at my urging the text and I dictated the necessary changes," he said, referring to a book of interviews with a French journalist.