They were perhaps Dzhokhar Tsarnaev’s closest friends during his two years at college, an American classmate from high school and two Russian-speaking students from Kazakhstan. The Kazakhs seemingly had money and drove expensive cars. They entertained Mr. Tsarnaev at their off-campus apartment, and he partied with them in New York. One of them lent Mr. Tsarnaev a black BMW after he smashed his Honda Civic in an accident.

And in the wake of the twin bombs that exploded last month at the finish line of the Boston Marathon, federal prosecutors now say, the three showed just how close their friendship was: two of them decided to put a backpack and fireworks linking Mr. Tsarnaev to the blasts into a black trash bag, and toss it into a Dumpster. Prosecutors say the third later lied to investigators when asked about it.

The two Kazakhs, Dias Kadyrbayev and Azamat Tazhayakov, were charged on Wednesday with concealing evidence to obstruct the federal inquiry into the marathon bombings. Their American friend, Robel K. Phillipos, was charged with lying to impede the investigation.

The story behind their arrest, detailed in lengthy affidavits, paints a vivid portrait of Mr. Tsarnaev in the days after the bombing, and portrays a dorm-room scene of confusion as the three young men, stunned to realize that their friend was being sought as a terrorist, debated whether and how to help him.