A handout image made available by the Boston Police Department shows the knife brandished by Usaamah Abdullah Rahim, a 26-year-old terror suspect, before he was shot dead by police. (Boston Police Department/EPA)

A 26-year-old terrorism suspect who was fatally shot in Boston on Tuesday during a confrontation with FBI agents and Boston police had planned to randomly kill police officers in his home state, according to federal court documents.

In a criminal complaint made public on Wednesday, an investigator said that Usaamah Abdullah Rahim had recently bought three fighting knives on Amazon.com and at first planned to behead some unknown person in another state.

In a conversation with a friend, which was recorded by the FBI, Rahim spoke about “thinking with your head on your chest.” Both men laughed. The FBI said in an affidavit that the remark was “a reference to the practice of some foreign terrorist organizations to behead targets and place their heads on their chests in propaganda videos.”

The friend, David Wright of Everett, Mass., was arrested Tuesday and charged with conspiracy to obstruct justice. A third man was being questioned in Rhode Island, officials said.

U.S. law enforcement officials said that at one point, Rahim had discussed targeting Pamela Geller, the organizer of a Muhammad cartoon contest in Texas last month, where two men were killed by a security official during an attempted attack.

Usaama Rahim, 26, who had been under surveillance by the U.S. Joint Terrorism Task Force, was shot dead by Boston police on Tuesday. Police say they approached Rahim to talk to him when he pulled out a knife and was shot by officers. (Reuters)

“I was not told about this specific threat, but there has been a lot of chatter,” Geller said in an interview Wednesday. “This is a showdown for American freedom.”

A senior U.S. intelligence official said there have been threats against Geller. It was not clear whether Rahim had made any effort to carry out his threat against Geller, who lives outside Massachusetts.

Rahim, Wright and the unnamed third man had met on a Rhode Island beach to discuss the plot to kill police officers, according to the criminal complaint.

According to the complaint, Wright, 24, had urged Rahim to destroy his cellphone and computer before he carried out any attacks.

“Because, at the scene, at the scene, CSI will be looking for that particular thing and so dump it, get rid of that,” Wright said in a recorded call, according to the complaint. “At the time you are going to do it, before you reach your destination, you get rid of it.”

According to the complaint, Rahim planned to stage an attack at the beginning of June, telling Wright in a phone call that he was going to “go after” the “boys in blue,” which the FBI said referred to police officers.

“Cause, ah, it’s the easiest target and, ah, the most common is the easiest for me,” Rahim said, according to the complaint.

Approximately two hours after the phone conversation, a knife-wielding Rahim approached FBI agents and Boston police officers who ordered him to drop the weapon.

“You drop yours,” Rahim said, according to the complaint.

He “then moved towards the officers while brandishing his weapon, and he was shot by law enforcement,” the complaint states.

Julie Tate contributed to this report.