Police and the FBI search an Everett, Mass., home as part of an investigation by the Joint Terrorism Task Force after the fatal shooting of Usaama Rahim earlier in the day in Boston. (Cj Gunther/EPA)

An FBI agent and a Boston police officer shot and killed a man Tuesday who was the subject of a terrorism investigation and possibly had been radicalized by the Islamic State, law enforcement officials said.

Authorities wanted to question Usaama Rahim, 26, outside a drugstore in Boston at about 7 a.m. when he approached the agent and officer with what appeared to be a large military knife.

After refusing to drop the weapon, Rahim was shot, officials said.

“He turned and came at the officers,” Boston Police Commissioner William B. Evans told reporters at a news conference. “They do what they are trained to do. Unfortunately, they had to take a life.”

Evans said Rahim had been under surveillance by the Joint Terrorism Task Force in Boston. A law enforcement official said that Rahim had recently threatened police, prompting heightened concern about his activities.

Usaama Rahim, 26, who had been under surveillance by the U.S. Joint Terrorism Task Force, was shot dead by Boston police on Tuesday. Police say they approached Rahim to talk to him when he pulled out a knife and was shot by officers. (Reuters)

The exact nature of the threat was unclear, as was how long the task force had been watching Rahim.

After the shooting, Rahim’s brother said on Facebook that Rahim had been waiting to take a bus to work when the officers confronted him. The brother said Rahim was taken to a hospital, where he was pronounced dead.

The Suffolk County district attorney’s office is investigating the incident.

The threat from the Islamic State has grown as the terrorist group has attempted to lure people living in the United States into committing acts of terrorism, officials have said. The FBI has arrested dozens of people on terrorism charges in connection with the Islamic State.

FBI Director James B. Comey has previously said the bureau has opened investigations into possible homegrown extremists in all 50 states. He has described Islamic State propaganda as a serious threat.

At a news conference last month after a shooting in Garland, Tex., involving two men likely radicalized by the Islamic State, Comey said the group is pushing its “siren song” through social media and especially on Twitter.

The two men, who wanted to attack an event where cartoonists were drawing the prophet Muhammad, were killed in a shootout with police.

The propaganda “asks people to travel to the so-called cal­iphate to fight,” Comey said. “But if you can’t travel, kill where you are.”

Tuesday’s shooting comes on the heels of the Boston Marathon bombing trial. Last month, a jury found Dzhokhar Tsarnaev, 21, guilty on multiple charges in connection with the 2013 bombing that killed three people, including an 8-year-old boy, and wounded scores.

The same jury sentenced Tsarnaev to death.