HAVANA — Fidel Castro says he didn’t expect he’d live long enough to turn 87 this week after grave illness forced him from office in 2006, according to an essay carried by official media Wednesday.

In a long, wide-ranging article taking up three pages of Communist Party newspaper Granma, Castro, whose birthday was Tuesday, wrote about being stricken with a near-fatal intestinal ailment on July 26, 2006.

“As soon as I understood that it would be definitive I did not hesitate to cease my charges as president … and I proposed that the person designated to exercise that task proceed immediately to take it up,” the retired leader said, referring to his successor and younger brother Raul Castro.

“I was far from imagining that my life would be prolonged seven more years,” he added.

Castro stepped aside provisionally that year and retired permanently in 2008. He rarely appears in public these days, though photos and video of him are released occasionally through official media.

It was Castro’s first essay in more than four months. He stopped penning his semi-regular columns called “Reflections” last year, and ended a nine-month hiatus in April with a piece urging restraint amid elevated tensions on the Korean Peninsula.

In Wednesday’s essay, Castro also reflected on topics such as the death in March of his friend and close ally Venezuelan President Hugo Chavez, as well as the wonders of science.

“The sciences should teach us above all to be humble, given our congenital self-sufficiency,” he said. “Thus would we be better prepared to confront and even enjoy the rare privilege of existence.”

Castro also touched on key Cold War moments such as the Cuban Missile Crisis and the failed Bay of Pigs invasion, and said Soviet Premier Yuri Andropov told him in the early 1980s that Moscow would not step in if Cuba were to be invaded by its northern neighbor.

“He said that if we were attacked by the United States, we should fight alone,” Castro wrote. “We asked if they could supply us with free arms as (they had) up until that time. He said yes. We told him then: ‘Don’t worry, send us the weapons and we will take care of the invaders ourselves.'”

“Only a few of us knew about this because it would have been very dangerous for the enemy to have that information,” Castro said.

He added that former North Korean leader Kim Il Sung also aided Havana by providing 100,000 Kalashnikov assault rifles “without charging a cent.”

Last month Panama detained a cargo ship carrying an undeclared shipment of arms including missile systems and live munitions that were bound from Cuba to North Korea.

Havana has called it obsolete equipment and said it was being sent for repairs in North Korea.

On Tuesday a team of U.N. experts began inspecting the armaments and interviewing the ship’s crew to determine whether the shipment violated U.N. sanctions aimed at blocking the sale of sophisticated weaponry to North Korea.