The knife brandished by Usaamah Abdullah Rahim, a 26-year-old terrorism suspect, before he was shot dead by police. (Boston Police Department)

The Justice Department on Thursday revealed that a well-known Islamic State operative instructed a Boston-area man to kill Pamela Geller, the organizer of a controversial Muhammad cartoon contest in Texas last year.

In court documents, prosecutors said that Junaid Hussain, a British militant, had been communicating with Usaamah Abdullah Rahim, 26, who along with two friends discussed beheading Geller.

Rahim, however, changed his mind and instead decided to target a police officer. He was shot and killed in June 2015 in Roslindale, Mass., after he attacked members of an FBI-led surveillance team while wielding a large knife, officials said.

Hussain, 21, was killed in Raqqa, Syria, in August 2015 in a drone strike. He was a well-known militant involved in not only spreading Islamic State propaganda but also recruiting and planning attacks, officials said.

FBI Director James B. Comey has said previously that a Phoenix man who tried to attack the Muhammad cartoon contest in Texas was trading encrypted messages with an Islamic State operative. A senior U.S law enforcement official, speaking on the condition of anonymity to discuss the case, declined to identify that operative but said it was not Hussain. Another official described the person as a member of the group’s unit that runs external operations.

Prosecutors said Rahim, along with two associates, Nicholas Alexander Rovinski, 25, of Warwick, R.I., and his nephew, David Wright, 26, of Everett, Mass., began plotting a terror operation in the United States in early 2015.

According to the Justice Department, Wright in March 2015 drafted organizational documents for a “Martyrdom Operations Cell” and conducted Internet searches about firearms, tranquilizers and the establishment of secret militias in the United States. Rovinski conducted research on weapons that could be used to behead people, the authorities said.

Prosecutors said Hussain communicated directly with Rahim, who then communicated instructions to the other conspirators to kill Geller in New York, where she lives. They planned to kill her around the July 4 holiday, court documents show.

The FBI was closely monitoring the men, officials said, and would have arrested them had they tried to travel to New York.

After Rahim’s death, prosecutors charged Rovinski and Wright with conspiracy to provide material support to a terrorist organization. Prosecutors also revealed that Rovinski has written letters to Wright from prison “discussing ways to take down the U.S. government and decapitate non-believers.” Rovinski also pledged his allegiance to the leader of the Islamic State, according to court documents.

On Thursday, Rovinski and Wright were also charged in a superseding indictment with conspiracy to commit acts of terrorism transcending national boundaries.