The former president said he was almost broken out of prison and transported abroad.
The president disclosed this on Friday, December 8, 2017, while speaking at the 20th anniversary of the death of Shehu Musa Yar'Adua.
Yar'Adua was a retired major general who also served as Obasanjo's deputy when he was military head of state from 1976-1979.
The two were arrested and imprisoned in 1995 by the regime of then-military head of state, Sani Abacha, on allegations of plotting a coup.
They were both initially sentenced to death before the sentences were later commuted to life imprisonment; but Yar'Adua died in custody in 1997, a year before Obasanjo's release.
While recounting the time he spent in captivity, he said, "When Shehu died in prison, my international friends decided that they would use a commando plan to get me out of prison and they actually did.
"They made the plan, they raised the money and their plan was to get a helicopter to take me out of Yola prison and take me into Cameroon and they sent a message to me.
"But I told them that if you did, I would not come out of prison and that was when they dropped the idea of using commando effort to get me out because that would have defeated what we stood for, and we stood to face whatever consequences standing for Nigeria would cost us.
"It cost Shehu Yar'Adua his life. Those of us who believed in what Shehu Yar'Adua believed in are still alive. I think the only thing we can do is to allow the struggle to continue and we are not at the end of the struggle. If anything, we are in the middle of the struggle."
The former president also discussed the events that led to his imprisonment.
He said, "When I learnt that Shehu was first arrested I asked Abacha. He said he was not aware. I said it is not possible for a former No 2 to be arrested without the knowledge of the current No 1. Thereafter, Shehu was released.
"Later, Shehu was arrested again. I was also arrested. We were detained at different locations and we never got to see again until we were sentenced. We thereafter met at Kirikiri maximum prisons.
"It was a mistake to allow us to be together again. There at Kirikiri, we discussed at length. We strategised on Nigeria. Unfortunately, he died in prison and he could not fulfill his dreams for the country in his lifetime."
After his release from prison by the government of Abdulsalami Abubakar, Obasanjo went on to become Nigeria's president in 1999 and won reelection in 2003.