(Reuters)

From the moment a military judge handed down a 35-year prison term for Chelsea Manning in 2013, President Obama and some administration officials saw the sentence as excessive. “Nuts,” said one person close to Obama.

They said Manning, an Army private charged with disclosing troves of secret files to WikiLeaks, should be punished for her crime. But while Obama, a former law professor, was known for his tough stance on government leakers, he had also advocated for changing America’s often harsh, inconsistent sentencing practices.

Long before Manning’s attorneys submitted a second clemency request in November, Obama had considered the notion of “proportionate sentences” in evaluating the soldier’s case, as he had in decisions to grant clemency to more than 1,300 drug offenders.

The key question for the president was how much time Manning should serve. He and his advisers looked at other government leak cases, which indicated that 35 years was the longest sentence ever imposed for a leak conviction. By the time the second request came in, Manning had served six years, much of that time subjected to harsh treatment and solitary confinement.

In his decision to commute Manning’s sentence, made public this week, Obama knew he would face criticism, the person close to the president said, speaking on the condition of anonymity to discuss internal deliberations. “But he felt strongly it was the right thing to do.”

(Thomas Johnson,Gillian Brockell/The Washington Post)

The 11th-hour announcement was a stunning end to a legal saga that began six years earlier with the arrest of Manning, then a 22-year-old intelligence analyst in Baghdad.

The revelations contained in the more than 700,000 documents Manning provided to WikiLeaks captured worldwide attention, revealing for the first time details of the wars in Iraq and Afghanistan and diplomats’ secret and sometimes snarky reports about the countries where they served. They also rattled American officials, who feared the disclosures would undermine U.S. security and alienate allies.

Manning pleaded guilty to most of the charges facing her in a military court and, in 2013, received a lengthy sentence for a series of offenses, including violations of the Espionage Act. Soon afterward, Manning, formerly known as Bradley Manning, announced her intention to live as a woman and requested hormone therapy to begin a gender transition.

On Wednesday, Obama addressed his decision to commute Manning’s sentence, effective May 17, in the final news conference of his presidency. “Let’s be clear: Chelsea Manning has served a tough prison sentence,” he said.

“It made sense to commute — and not pardon — her sentence,” he continued. “I feel very comfortable that justice has been served and that a message has still been sent.”

Obama’s announcement adds to the list of executive actions opposed by President-elect Donald Trump, who takes office Friday.

“It sends a very troubling message when it comes to the handling of classified information and to the consequences to those who leak information that threatens the safety of our nation,” Sean Spicer, a spokesman for Trump, told reporters.

Obama’s decision, ending an extended campaign by Manning supporters to secure her release, also divided the most senior levels of the U.S. government. From the start, military officials had seen Manning’s actions as treasonous, a breach of the oath service members take to safeguard U.S. security.

When the White House asked Defense Secretary Ashton B. Carter for his opinion, he recommended against commutation, one defense official said. The secretary, like others in the Pentagon, viewed the airing of leaks as highly damaging to the U.S. military in particular and worried about the effect clemency would have on military discipline.

One of the first items made public by WikiLeaks was a chilling video of the 2007 killing of a group of Iraqis, including two journalists with the Reuters news agency, in an Apache helicopter attack in Baghdad. Reuters had sought to secure the release of information regarding that event but was rebuffed for years by the Pentagon.

Typically, petitions to reduce federal sentences go to the Pardon Attorney’s Office in the Justice Department, where Justice officials make recommendations to White House Counsel W. Neil Eggleston about which requests should be granted. Manning’s clemency request, meanwhile, would typically go through the Army because the trial occurred in a military court.

Although Manning’s attorneys submitted the November clemency request to the Army, the Justice Department and the White House counsel’s office, the White House handled the deliberation.

On Tuesday, after the commutation was announced, White House officials said Obama‘s decision was motivated in part by the fact that Manning had apologized for her actions.

“Chelsea Manning is somebody who accepted responsibility for the crimes she committed,” one official said.

Obama on Wednesday dismissed the idea that his act of clemency was aimed at securing the extradition of WikiLeaks founder Julian Assange, who has taken refuge in the Ecuadoran Embassy in London. Although Assange had promised to submit to extradition if Manning was pardoned, U.S. officials have said he is unlikely to face charges here.

“I don’t pay a lot of attention to Julian Assange’s tweets, so that wasn’t a consideration in this decision,” the president said.

Even as White House officials prepared to make Tuesday’s surprise announcement, Manning and her legal team remained in the dark hours before it took place.

Nancy Hollander, one of Manning’s attorneys, said her legal team believed they “had only a tiny chance” of succeeding in the months after they submitted the clemency request. In 2013, Manning had requested pardon but was denied.

Hints of a shift in White House thinking began to emerge last week, beginning with a news report that Manning was on a “shortlist” for potential clemency action.

On Friday, White House press secretary Josh Earnest, speaking to reporters, identified a “stark difference” between Manning and Edward Snowden, the former intelligence contractor who leaked secret files to the media.

Unlike Snowden, who secured asylum in Russia, Manning had faced the charges against her and acknowledged her mistakes, Earnest said.

More than six years after her arrest, Manning told one of her attorneys, she had begun to imagine life beyond her cell at the military detention center in Fort Leavenworth, Kan.

Chase Strangio, an American Civil Liberties Union attorney, was growing optimistic but worried about what would occur if Manning was ultimately denied.

Manning had already attempted suicide twice. Struggling to get treatment for gender dysphoria, she launched a hunger strike in the fall.

“I was both hopeful but also incredibly concerned about the consequences” if the request was rejected, Strangio said. To lurch from renewed hope to having to “go on with the 28 years” behind bars could be severely damaging, Strangio feared.

Several hours after that call, Hollander was on the phone at her practice in Albuquerque when her assistant broke in to notify her that the White House counsel’s office was calling.

Her expectations changed instantly. “They wouldn’t call to say it was denied,” she said.

“This is a vindication for her, that certainly her sentence was too long,” Hollander added. “It means also that she can start her life.”

Karen DeYoung and Ellen Nakashima contributed to this report.