The American soldier Chelsea Manning has accused US military guards of threatening her with exile to Guantánamo Bay without trial or acknowledgment of her gender transition after she was apprehended as the source of one of the largest leaks of state secrets in history.

Writing in the Guardian from prison at Fort Leavenworth in Kansas, where she is serving a 35-year sentence, Manning marked the fifth anniversary of her military custody on Wednesday with the most personal first-hand account she has yet given of the “physical and emotional rollercoaster” of a whistleblower behind bars. She describes her initial arrest, her harsh treatment at a US marine brig in Virginia and her ongoing legal battle to be allowed treatment for gender dysphoria, which has reached the highest levels of government.

After her arrest on 27 May 2010, a then-22-year-old Manning “expected the worst possible outcome”, she writes, but was still unprepared for the intensity of the US government’s wrath. She recalls being flown under guard to Kuwait and then caged in a large tent, only to grow extremely depressed, fearing that she would be “disappeared” by US officials hell-bent on branding her the enemy.

I began to fear that I was forever going to be living in a hot, desert cage

“I began to fear that I was forever going to be living in a hot, desert cage, living as and being treated as a male, disappearing from the world into a secret prison and never facing a public trial.”

Manning, now 27 and a contributing opinion writer for the Guardian, discloses in her op-ed that she was threatened from detention in Kuwait by some of her navy captors with interrogation “on a US cruiser off the coast of the horn of Africa, or being sent to the prison camps of Guantánamo Bay”.

Paradoxically, one key aspect of the document stash Manning leaked to the open information organization WikiLeaks was to expose previously hidden details of the US detainees at the Guantánamo camp; she was intimately aware of the potential consequences of transfer there.

The army private, then known under her birth name Bradley Manning, was arrested five years ago at the Forward Operating Base Hammer outside Baghdad, where she was working as an intelligence analyst. She was later prosecuted as the source of a vast mountain of confidential files, including logs kept by the US military in Iraq and Afghanistan that gave a level of detail about modern warfare never before made public.

Details of Manning’s ordeal have gradually emerged in the years since, through her prolonged military trial, her writings from prison largely for the Guardian, and her recently opened Twitter account. But she has never before offered such a detailed portrait of her journey from Baghdad to Kansas.

In her latest Guardian article, Manning traces her motivation for leaking back to the immediate astonishment she felt upon reading the war logs from Afghanistan and Iraq.

“Once you come to realize that the coordinates in these records represent real places, that the dates are our recent history and that the numbers represent actual human lives – with all of the love, hope, dreams, hate, fear and nightmares with which we all live – then you cannot help but be reminded just how important it is for us to understand and, hopefully, prevent such tragedies in the future,” Manning writes.

She recounts her “very lowest point” over the past five years – the moment in Kuwait, stuck in the desert tent, where she saw little hope for the future and contemplated castrating or killing herself.

Manning also recalls being on trial for more than 100 days, hearing herself being described as a “traitor” and “enemy of the state” by US prosecutors who nonetheless, she says, were “basically just decent people doing their jobs”.

The high point of the past five years, Manning writes, was announcing to the world after she was sentenced that she was changing her name from Bradley to Chelsea and transitioning to live as “the woman I have always been”. Even then, however, it took more than a year of legal wrangling to force the US military to allow her hormone treatment in custody; she is still fighting for permission to grow her hair to standard military length for female personnel.

Manning ends her Guardian op-ed on a note of promise: despite many struggles, she writes that she has not only survived the ordeal of being, alongside Edward Snowden, the world’s most famous official leaker – she has matured and grown. She even uses, from prison, the word “thrive”.