Prosecutors have charged two men with conspiracy to provide material support to Islamic State following a terrorism-related investigation that also led to the police shooting of a knife-wielding suspect Usaamah Abdullah Rahim. (Reuters)

Two men who were part of an alleged plot to kill a police officer in Massachusetts have been charged with conspiring to provide material support to the Islamic State, federal prosecutors in Boston announced Friday.

The conspiracy unraveled earlier this month after authorities fatally shot a suspected third accomplice, Usaamah Abdullah Rahim, 26, after he tried to attack FBI agents and Boston police officers with a knife.

Prosecutors said that David Wright, 25, of Everett, Mass., and Nicholas Rovinski, 24, of Warwick, R.I., along with Rahim, had also discussed beheading Pamela Geller, the organizer of a Muhammad cartoon drawing contest in Texas in early May.

The FBI said that on May 31 Wright and Rahim drove to Rhode Island and picked up Rovinski at his house in Warwick. The trio then drove to a nearby beach to discuss in secret a potential attack on Geller but did not realize the FBI was monitoring them.

On June 2, Rahim abruptly changed plans and decided to kill a police officer in his home state of Massachusetts.

This undated self-portrait shows Usaamah Abdullah Rahim, who was shot to death after he tried to attack FBI agents and Boston police officers on June 2. (via AP)

In a recorded conversation, Rahim told Wright that he intended to attack “those boys in blue,” which the FBI said referred to police officers.

Prosecutors said the three men thought that attacks inside the United States would support the Islamic State’s objectives.

After the shooting, prosecutors had charged Wright, Rahim’s nephew, with conspiracy to obstruct justice. The FBI said that Wright told Rahim to wipe clean his laptop computer and destroy his phone to help cover their tracks.

Wright was previously in custody while Rovinski was arrested Thursday night at home in Warwick.

Rovinski is expected to make an initial appearance Friday in federal court.

In a previous interview, Geller said she was aware of threats against her life and had hired personal security.

Authorities killed two men who were about to attack the event in Texas, which jihadists had targeted on social media.