The first high-value detainee at Guantanamo Bay to strike a plea bargain with the U.S. government will serve no more than 19 years in exchange for his full cooperation, including providing testimony at the military commission trials of other detainees.

Wearing a dark business suit and sporting a short haircut and a closely trimmed goatee, Majid Khan, a former resident of the Baltimore suburbs, pleaded guilty to five war crimes, including murder, attempted murder and spying.

Sentencing has been delayed for four years, and if Khan fails to cooperate, he could receive up to 25 years. The deal calls for him to provide “complete and accurate information in interviews, depositions and testimony wherever and whenever requested by the prosecutors.”

Before Sept. 11, 2001, Khan worked for Electronic Data Systems in Northern Virginia, and on the day of the attacks he watched smoke rise from the Pentagon from his office building in Tysons Corner, according to court documents.

In the documents, Khan, a Pakistani citizen, acknowledges that he flew to Pakistan after Sept. 11 and volunteered to work for Khalid Sheik Mohammed, the self-proclaimed mastermind of the attacks.

Over the course of a year, before his capture in March 2003, court documents state that Khan couriered $50,000 to al-Qaeda associates to fund a hotel bombing in Jakarta, Indonesia; discussed terrorist strikes in the United States, including poisoning water reservoirs; and agreed to a suicide attack to assassinate the president of Pakistan, Pervez Musharraf.

When the plot against Musharraf failed — he did not show up to the planned site of the attack — Mohammed was visibly upset and threw down his cellphone, according to the court documents.

On Wednesday, as the judge described the elements of the conspiracy to which Khan was pleading guilty, including the involvement of Osama bin Laden, the detainee occasionally appeared agitated. He stressed that he had never met bin Laden and that by the time of the hotel bombing, in August 2003, he was in CIA custody after what he called his “illegal kidnapping.”

At other times, Khan appeared relaxed. At one point, he smiled at two FBI agents on the prosecution side and pumped his fist. The agents smiled back.

When the judge said he could continue to be held under the laws of war even after he serves his sentence, Khan said, “I’m making a leap of faith here, sir; that’s all I can do.”

As part of the plea, Khan agreed to never sue the U.S. government for his treatment. When he began to speak about the CIA — which held him at an overseas secret prison for three years before his transfer to the U.S. military facility at Guantanamo Bay — a court security officer cut the audio feed to the public gallery.

Lt. Col. Jon Jackson, Khan’s military counsel, said that his client had pushed for a deal for a long time and wanted a “second chance in life.”

“He’s remorseful; he wished he had never been involved with al-Qaeda,” Jackson said.

Referring to Khan’s cooperation, Jackson said his client’s plan over the “next four years is to join Team America.”

The chief military prosecutor at Guantanamo Bay, Brig. Gen. Mark Martins, said he thought the outcome in Khan’s case was just.

“No one has alleged that he was a mastermind or a leader,” Martins said. “He’s done very serious things.”

Under the terms of the plea agreement, a senior Pentagon official who will ultimately approve Khan’s sentence has agreed to try to ensure that he will no longer be held at Camp 7, the high-security facility where high-value detainees, including Mohammed, are kept.

The deal doesn’t specify whether Khan will testify against Mohammed, but it seems likely.

Pat Pond, a California resident who was on a business trip to Jakarta and having lunch in the JW Marriott when the suicide bomber struck there, attended the proceeding Wednesday.

“It seems fair to me,” said Pond, 62, who suffered cuts and burns and was infected with HIV through a contaminated needle while being treated in a hospital in the aftermath of the attack.

The defense unsuccessfully attempted to have the plea deal sealed by Judge James Pohl, an Army colonel. The defense said the terms could present a threat to Khan’s family in Baltimore and Pakistan. The government, arguing that much of the information was in the public domain, opposed the motion.