Dias Kadyrbayev, 20, is accused of removing a backpack containing a laptop and fireworks casings emptied of gunpowder that can be used to make bombs from Tsarnaev`s dorm room after realizing his friend was suspected of carrying out the attack.

"He made an error in judgment that he is paying for dearly," attorney Robert Stahl said after the hearing in US District Court in Boston.

Prosecutors said Kadyrbayev and another Tsarnaev friend, Azamat Tazhayakov, took the backpack and its contents just hours after the FBI released photographs of Tsarnaev and his brother Tamerlan as suspects in the bombings.

The two friends then tossed the backpack in the trash, keeping the computer.

Tsarnaev had texted the pair while on the run, saying "if you want to go to my room and take what`s there," according to prosecutors.

"Ha Ha :)" Tazhayakov replied.

The FBI recovered the backpack from a nearby landfill. Inside were fireworks allegedly used in bomb making, a jar of Vaseline, and a thumb drive for a computer. Twin bombs planted at the marathon finish line on April 15, 2013 killed three people and injured 264. The Tsarnaev brothers, of Chechen origin, are blamed for the attack.

Under a plea deal, which skirts a trial that had been due to begin next month on obstruction of justice and conspiracy charges, prosecutors agreed to ask for no more than seven years in prison for Kadyrbayev.

He is due to be sentenced on November 18.

Kadyrbayev, a citizen of Kazakhstan, was in the United States on a student visa attending the University of Massachusetts at Dartmouth when he became friends with fellow Russian-speaking student Tsarnaev.

"Let me be very clear that Dias did not know that Dzhokar or Tamerlan Tsarnaev were planning the marathon bombing," Stahl said.

"He, like the rest of the world that knew the Tsarnaevs here in the community, (was) shocked that someone they knew and thought they knew so well would be involved in something so horrendous."

Tazhayakov was the first person to be convicted in the case. He faces up to 25 years in prison.

A total of three former students have been linked to the case.

A third college friend, Robel Phillipos, faces lesser charges of lying to investigators about his whereabouts the night the evidence was allegedly removed. His trial is scheduled for September 29.

Tsarnaev, 21, is due to stand trial in November -- he is accused of 30 federal charges and faces the death penalty if convicted.

Police shot dead his older brother after the attacks.

Tsarnaev`s defense team is attempting to delay the start of the trial and have it moved to Washington, arguing it cannot find an impartial jury in Boston.