WASHINGTON — Feeling outcast and alone in Iraq, Bradley Manning, then a 22-year-old Army private, turned to the Internet for solace in early 2010, wanting to share with the world what he saw as the unconscionable horrors of war, an act that resulted in what military prosecutors called one of the greatest betrayals in the nation’s history.

Within months, he was arrested for making public, through the WikiLeaks organization, the greatest cache of secret government information since the Pentagon Papers. He was called a traitor by his government; confined to a tiny cell 23 hours a day at the Marine base at Quantico, Va., and the Army brig at Fort Leavenworth, Kan.; and finally court-martialed in Maryland.

As prosecutors accused Private Manning of being a self-promoting “anarchist” who was nothing like the tortured man of principle portrayed by his lawyers, supporters around the world celebrated him as a martyr for free speech. But the heated language on both sides tended to overshadow the human story at the center of the case.

That story involved the child of a severed home, a teenager bullied for his conflicted sexuality whose father, a conservative retired soldier, and mother, a Welsh woman who never adjusted to life in Oklahoma, bounced their child back and forth between places where he never fit in.