By Scott Malone

BOSTON (Reuters) - Prosecutors in Boston on Monday released a video of the fatal police shooting last week of a man who had been under surveillance in a terrorism investigation, showing officers initially retreating before opening fire.

Usaamah Abdullah Rahim had been under 24-hour watch by the Joint Terrorism Task Force when FBI agents and a Boston police officer approached him on Tuesday in a parking lot to question him after wire-tapped phone calls revealed that he planned to try to behead police officers, in an attack apparently inspired by Islamic State militants.

According to court papers filed by the Federal Bureau of Investigation, Rahim, a 26-year-old security guard, threatened officers with a large knife and was shot and killed after ignoring orders to drop the weapon.

The video shows a group of five FBI agents and one Boston police officers approaching a person prosecutors identified as Rahim, who was black and Muslim, and twice dropping back from him before two people opened fire on him. Faces and weapons could not be clearly seen in the grainy video, which depicts an incident that played out in seconds.

"This video ... is simply one piece of evidence among many and this investigation is very active," said Suffolk Country District Attorney Daniel Conley, whose office is reviewing whether the police and FBI agents involved in the shooting broke any laws. "This is an exacting process and it requires a careful evaluation of all the evidence."

Members of Rahim's family and community leaders from the Roslindale neighborhood where he lived and where the shooting occurred were shown the video last week, but prosecutors put off releasing it publicly until after Rahim's funeral, which was held on Friday.

Rahim's oldest brother, Ibrahim Rahim, initially claimed that his brother had been shot in the back. A lawyer for the family later apologized on Ibrahim Rahim's behalf, saying the statement had been based on inaccurate information.

Federal investigators contend Rahim had discussed his plans to behead officers with two people, including his nephew, David Wright. Wright was arrested the day of Rahim's shooting and charged with conspiracy to obstruct justice for allegedly telling Rahim to destroy his laptop and cell phone to prevent them from being used as evidence against him.

The third person has not been publicly identified.

Rahim's family has said they saw no evidence that he had adopted extremist views.

Boston Police Commissioner William Evans defended the officers. "I think he was intent ... on getting a 'boy in blue' ... there were multiple, multiple requests for him to put down that weapon," he said.

(Reporting by Scott Malone; Editing by Mohammad Zargham, Bernard Orr)