In court papers, the FBI said one of them threw the backpack in the garbage - it was later found in a landfill by law enforcement officers - after they concluded from news reports that Tsarnaev was one of the bombers.
Azamat Tazhayakov and Dias Kadyrbayev were charged with conspiring to obstruct justice by concealing and destroying evidence. A third man, Robel Phillipos, was charged with lying to investigators about the visit to Tsarnaev's room.
A court appearance for the three was scheduled for Wednesday afternoon. Their lawyers refused to comment ahead of the hearing.
Three people were killed and more than 260 injured on April 15 when two bombs exploded near the finish line. Tamerlan Tsarnaev died after a gunfight with police days later. His younger brother, Dzhokhar Tsarnaev, a 19-year-old sophomore at the University of Massachusetts at Dartmouth, was captured and lies in a prison hospital.
Tazhayakov and Kadyrbayev, who are from Kazakhstan, have been held in jail for more than a week on allegations that they violated their student visas by not regularly going to class at UMass. All three men charged Wednesday began attending UMass with Tsarnaev at the same time in 2011, according to the FBI.
The three were not accused of any involvement in the bombing itself. But in a footnote in the court papers, the FBI said that about a month before the bombing, Tsarnaev told Tazhayakov and Kadyrbayev that he knew how to make a bomb.
Investigators have not said whether the pressure cooker bombs used in the attacks were made with gunpowder extracted from fireworks.
If convicted, Kadyrbayev and Tazhayakov could get up to five years in prison and a $250,000 fine. Phillipos faces a maximum of eight years behind bars and a $250,000 fine.
Authorities allege that on the night of April 18, after the FBI released surveillance-camera photos of the bombing suspects and the three men suspected their friend was one of them, they went to Tsarnaev's dorm room.
Before Tsarnaev's roommate let them in, Kadyrbayev showed Tazhayakov a text message from Tsarnaev that read: "I'm about to leave if you need something in my room take it," according to the FBI.
When Tazhayakov learned of the message, "he believed he would never see Tsarnaev alive again," the FBI said in the affidavit.
It was not clear from the court papers whether authorities believe that was an instruction from Tsarnaev to his friends to destroy evidence.
Once inside Tsarnaev's room, the men noticed a backpack containing fireworks, which had been opened and emptied of powder, the FBI said.
The FBI said that Kadyrbayev knew when he saw the empty fireworks that Tsarnaev was involved in the bombings and decided to remove the backpack from the room "in order to help his friend Tsarnaev avoid trouble."
Kadyrbayev also decided to remove Tsarnaev's laptop "because he did not want Tsarnaev's roommate to think he was stealing or behaving suspiciously by just taking the backpack," the FBI said in court papers.
After the three men returned to Kadyrbayev's and Tazhayakov's apartment with the backpack and computer, they watched news reports featuring photographs of Tsarnaev.
The FBI affidavit said Kadyrbayev told authorities the three men then "collectively decided to throw the backpack and fireworks into the trash because they did not want Tsarnaev to get into trouble."
Kadyrbayev said he placed the backpack and fireworks along with trash from the apartment into a large trash bag and threw it into a garbage bin near the men's apartment.
When the backpack was later found in a landfill last week, inside it was a UMass-Dartmouth homework assignment sheet from a class Tsarnaev was taking, the FBI said.
Meanwhile, Tamerlan Tsarnaev's relatives will claim his body now that his wife has agreed to release it, an uncle said. The body of Tsarnaev, 26, has been at the medical examiner's office in Massachusetts since he died after a gunfight with authorities more than a week ago.
Amato DeLuca, an attorney for his widow, Katherine Russell, said Tuesday that his client had just learned that the medical examiner was ready to release Tsarnaev's body and that she wants it released to his side of the family.
Tsarnaev's parents are still in Russia, but he has other relatives in the U.S.
Contributing to this report were Associated Press writers Michelle R. Smith in Providence; Rodrique Ngowi in Boston; Lynn Berry in Moscow; Arsen Mollyaev in Makhachkala, Russia; and Eric Tucker, Alicia A. Caldwell, Eileen Sullivan and AP Intelligence Writer Kimberly Dozier in Washington.