In 2013, Daniel Hale was at an antiwar conference in D.C. when a man recounted that two family members had been killed in a U.S. drone strike. The Yemeni man, through tears, said his relatives had been trying to encourage young men to leave al-Qaeda.

Hale realized he had watched the fatal attack from a base in Afghanistan. At the time, he and his colleagues in Air Force intelligence viewed it as a success. Now he was horrified.

It was such experiences, Hale told a federal judge in Alexandria, Va., on Tuesday, that led him to leak classified information about drone warfare to a reporter after leaving the military.

“I believe that it is wrong to kill, but it is especially wrong to kill the defenseless,” he said in court. He said he shared what “was necessary to dispel the lie that drone warfare keeps us safe, that our lives are worth more than theirs.”

U.S. District Judge Liam O’Grady sentenced Hale, 33, of Nashville, to 45 months in prison for violating the Espionage Act, saying his disclosure of documents went beyond his “courageous and principled” stance on drones.

“You are not being prosecuted for speaking out about the drone program killing innocent people,” O’Grady said. “You could have been a whistleblower . . . without taking any of these documents.”

Hale had pleaded guilty to one of five charges related to his dissemination of the documents; at sentencing, O’Grady dismissed the other four with prejudice, meaning they cannot easily be brought against him again.

Hale’s attorneys and advocates argued that the disclosures provided a valuable public service. The documents included a report finding that reliance on deadly attacks was undermining intelligence gathering. During one five-month stretch of an operation in Afghanistan, the documents revealed, nearly 90 percent of the people killed were not the intended targets.

Hale also disclosed the criteria for placing a person on the terrorism watch list, information that Muslim civil rights lawyers said in a letter to the court had helped them challenge the constitutionality of that system.

“I believe he only spoke out for humanitarian and educational purposes,” journalist Sonia Kennebeck told the court in a letter. She featured Hale in a 2016 documentary about drone warfare.

Prosecutors countered that Hale had put Americans at risk to boost his own ego. They noted that he began taking classified information to his home only a few weeks into a job at the National Geospatial-Intelligence Agency in 2014, not long after swearing to preserve the government’s secrets.

“Hale did not in any way contribute to the public debate about how we fight wars,” Assistant U.S. Attorney Gordon Kromberg said in court. “All he did was endanger the people who are doing the fighting.”

Friends and family members said military service was an awkward fit for Hale, who suffered from mental health issues throughout his life. His attorney said he joined the Air Force to escape an abusive atmosphere in a poor, fundamentalist home.

“Recently, someone asked me to tell them a happy memory I have with Daniel,” his sister wrote to the court. “Sadly, this was not an easy task.”

But Hale tested well and was steered into signals intelligence. He went to Afghanistan in 2012. When he left the following year, he said, he already had deep misgivings about the work he had done. He recalled in a letter to the judge learning after one drone strike on a car that a small child had been killed and another seriously injured. He wondered whether any of the other strikes he had helped carry out had killed innocent civilians deemed “enemy combatants” by virtue of being male and of military age.

“You had to kill part of your conscience to keep doing your job,” he said in court Tuesday.

He began connecting with journalists and activists critical of the use of drones, but he also took a new job at a defense contractor in 2014. One day after work, he said, two colleagues invited him to watch footage of drone strikes.

“My conscience, once held at bay, came roaring back to life,” he wrote. He printed out over three dozen documents, some classified, the government said, and shared several with Jeremy ­Scahill, a reporter for the Intercept.

Authorities searched Hale’s home in 2014, his attorneys said — before the documents were published. But he was not charged or arrested until 2019. Between 2014 and 2019, he worked on and off in restaurants, and he adopted a cat. In October, while awaiting resolution in this case and staying in Brightwood Park, Hale witnessed the death in a moped crash of 20-year-old Karon Hylton during what some have described as a chase by police; a friend told the court that Hale has cooperated with that investigation.

He mused about becoming a reporter himself, leading prosecutors to argue that his motive had been self-aggrandizement.

In his letter, Hale said that he has been diagnosed with post-traumatic stress disorder and often wonders whether he is “deserving of my life and the right to pursue happiness.”

None of the government agencies involved reported any direct harm resulting from Hale’s disclosures. But the Justice Department said two of the leaked documents were incorporated into an online guide for Islamic State fighters to avoid detection, and that the documents contained details useful to foreign governments and terrorist groups.

Much of what Hale disclosed was unrelated to his work, the government said, and so he could not know how damaging its release would be.

“I’m sure it wasn’t Mr. Hale’s intention to support ISIS, but that’s what he did,” Kromberg said in court.

The Justice Department sought a nine-year sentence, which would have been the longest yet in a leak case.

Such prosecutions were rare until the Obama and Trump administrations, when they became increasingly common. Under President Biden, the Justice Department has banned the use of secret orders and subpoenas to obtain journalists’ information. But the Justice Department is still pursuing an espionage case against WikiLeaks founder Julian Assange that began under Trump.

A group of First Amendment and media law scholars wrote to the court in support of Hale, calling him “a classic whistleblower, who acted in good faith to alert the public of secret government policies that deserved to be debated by the citizens in a truly functioning democracy.”

They argue that the Espionage Act was intended to punish foreign spies, not those who seek to enlighten the American people. Only one appeals court has approved the use of the Espionage Act against leakers, in a case involving financial motivation.

Hale had tried and failed to challenge his prosecution as violating his right to free speech. Even if no journalist is charged, his attorneys argued, prosecuting those who share information with journalists has a chilling effect.

The government countered that in the Internet age, information doesn’t have to go directly to foreign adversaries to undermine national security and said that Hale gave up any ability to argue that his actions were legal when he signed nondisclosure agreements.

Biden has pulled narrowed the freedom the Trump administration gave the military and CIA to conduct drone strikes outside of the battlefields of Afghanistan, Syria and Iraq. But the new administration has lowered the bar for airstrikes in Iraq and Syria.

Relatives of the two men killed in Yemen in 2012 sued unsuccessfully in U.S. federal court.

In court, Hale said he is a descendant of Nathan Hale, who was executed for spying on the British during the Revolutionary War. Quoting a line often attributed to his ancestor, he said he accepted punishment for taking the documents and for taking innocent lives.

“I have but this one life to give in service of my country,” he said.