BOSTON — Prosecutors will not seek criminal charges against a Boston officer and an FBI agent who fatally shot a man last year who they believed was plotting an attack against police, authorities announced on Wednesday.

“The use of deadly force was a lawful exercise of self-defense,” Suffolk District Attorney Daniel Conley said.

Usaamah Rahim, 26, was shot June 2, 2015, in the city’s Roslindale neighborhood. Rahim had been under 24-hour surveillance for several months as part of an investigation into his ties with the Islamic State, including a plot with two co-conspirators to behead a political activist in New York City, according to authorities.

The morning of the shooting, a recorded phone conversation revealed that Rahim had abandoned his plans to travel to New York and was instead planning to attack officers in Boston, Conley said.

“It was clear from this recorded conversation that Mr. Rahim did not expect to survive this attack,” he said.

Terror investigators approached Rahim at a bus stop, at which point Rahim drew a large, military-style knife from a sheath, Conley said.

Rahim was shot three times.

Nicholas Rovinski of Warwick, Rhode Island, and David Wright of Everett, Massachusetts, are facing federal charges they plotted with Rahim to kill civilians.