BOSTON (AP) — A knife-wielding man killed by the terror investigators who had him under surveillance was confronted because he had bought knives and talked of an imminent attack on "boys in blue," the FBI said Wednesday.

Usaama Rahim, 26, plotted for at least a week to attack police, the FBI said in a complaint against a family member who was arrested Tuesday, the day Rahim was shot to death. On Wednesday, David Wright, who authorities say is Rahim's nephew, was ordered held on a charge of conspiracy with intent to obstruct a federal investigation.

The FBI said Rahim, who had previously discussed beheadings, bought three fighting knives and a sharpener on or before May 26 and he told 24-year-old Wright on Tuesday he would begin trying to randomly kill police officers.

An anti-terror task force of FBI agents and Boston police, faced with an imminent threat, confronted Rahim on a sidewalk and fatally shot him when he refused to drop his knife, authorities said.

An affidavit written by an FBI agent assigned to Boston's Joint Terrorism Task Force refers to a recorded conversation between Rahim and Wright in which Wright made a comparison to "thinking with your head on your chest." The FBI said that was a reference to Islamic State propaganda videos showing severed heads on the chests of beheading victims.

The FBI affidavit said Rahim initially told Wright about a plan to behead someone outside Massachusetts. On Sunday, Rahim, Wright and an unidentified man met on a beach in Rhode Island to "discuss their plans," the FBI affidavit said.

"Wright indicated that he agreed with Rahim's plan and supported it," the affidavit states.

Authorities searched a home in Warwick, Rhode Island, on Tuesday and Wednesday but wouldn't confirm the search was related to the investigation.

Early Tuesday morning, Rahim called Wright and told him he had changed his plans and no longer planned to kill someone in another state, the affidavit says. Instead, he said he was going to "go after" the "boys in blue," it says, an apparent reference to police officers.

During the recorded conversation, Rahim told Wright, "Yeah, I'm going to be on vacation right here in Massachusetts. ... I'm just going to, ah, go after them, those boys in blue. Cause, ah, it's the easiest target and, ah, the most common is the easiest for me," the affidavit says.

The FBI said the phrase "going on vacation" refers to committing violent jihad.

Authorities allege that during that conversation, Wright advised Rahim to destroy his smartphone, wipe his laptop computer and prepare his will.

On Wednesday, authorities moved swiftly to manage perceptions of the shooting, which killed a black man whose family is well known among Muslims and African-Americans in Boston.

Rahim's mother is a nurse at Boston University. His older brother, Ibrahim Rahim, is a scholar known for preaching after the Boston marathon bombings that violence is anti-Islamic.

Ibrahim Rahim initially posted a message on Facebook alleging police repeatedly shot his brother in the back while he was on a cellphone calling their father for help. But his version unraveled Wednesday after police showed their video of the confrontation to community leaders.

Darnell Williams, president of the Urban League of Eastern Massachusetts, said he could "150 percent corroborate" the police account. The images clearly show that Usaama Rahim "was not on a cellphone and was not shot in the back," Williams said.