UPPER DARBY, Pa. — A man who had posted an online video threatening to kill police and FBI agents tried to use his car to run down officers seeking to arrest him on Tuesday so, fearing for their lives, they shot and killed him, authorities said.

Police did not immediately identify the man, who was killed in Upper Darby, in suburban Philadelphia, as officers ordered him out of the car and he appeared ready to accelerate at them as they manned a blockade.

Police Superintendent Michael Chitwood said the officers feared the man would kill them and they “did what they had to do.” He said five officers fired at the man and no officers were injured.

Police had secured an arrest warrant for the man after he threatened to kill police and FBI agents in the online video, Chitwood said. The man’s death comes a little more than a week after a man who made similar threats shot two New York Police Department officers dead in their patrol car and then killed himself in a subway station.

Police said they began following the man after he left a home in nearby Clifton Heights. They said when officers stopped him at an intersection and ordered him out of the car, he reversed and slammed into a police vehicle and then prepared to run over other officers.

Officers opened fire, killing the man, Chitwood said. The man did not fire at police, and Chitwood said he did not know if the man had a weapon.

In the New York case, Officers Rafael Ramos and Wenjian Liu were ambushed on a Brooklyn street as they sat in their marked car on Dec. 20. Their attacker, Ismaaiyl Brinsley, had referenced in online posts the high-profile killings by white police officers of unarmed black men, specifically Michael Brown in Ferguson, Missouri, and Eric Garner on Staten Island. Soon after the officers’ shooting Brinsley, who was black, killed himself.

Decisions by grand juries not to indict the officers involved in the killings of Brown and Garner have sparked protests around the nation, with demonstrators lying down in the streets as though they’re dead. Many protesters have chanted “Hands up! Don’t shoot!” a reference to their contention Brown’s hands were raised when he was shot dead by police, and “I can’t breathe,” which Garner was heard saying on a video recording of his encounter with a policeman who put his arm around his neck.

On Sunday night, two men opened fire on a police car patrolling a tough part of Los Angeles, but the two officers inside were not injured and one was able to shoot back, authorities said. One suspect was later arrested, and the other was on the loose. Police haven’t determined a motive for the shooting in South Los Angeles, an area plagued by gang violence, but said there were no indications it was linked to other attacks on police.