A Brentwood resident has been arrested after punching a state trooper and a 71-year-old man in one of two failed carjackings in the hamlet, police said Thursday.

James Townsend, 26, is charged in the Wednesday incidents with assault and attempted robbery and is scheduled to be arraigned Thursday, according to a State Police news release.

advertisement | advertise on newsday

Townsend was arrested after troopers assigned to the High Intensity Gang Initiative were conducting a traffic stop on Fifth Avenue just north of Third Avenue at 6:10 p.m. when they were flagged down by a man, 71, who said another man had just assaulted him and attempted to steal his 2002 Hyundai Santa Fe at the Speedway gas station.

As the troopers moved in to question Townsend, he punched one of them in the face and was quickly taken into custody, the release added. No injuries were reported, police said.

A subsequent investigation revealed that Townsend had assaulted the 71-year-old, punching him in the face, and attempted to steal his car just before troopers arrived.

State Trooper spokesman Frank Bandiero said the investigating troopers also learned that at “around the same time” of the Hyundai’s attempted carjacking, Townsend had also attempted to carjack another man, 26, at the gas station who was driving a 2005 Toyota Corolla. That person was not assaulted.

advertisement | advertise on newsday

Bandiero said the first victim was able to identify Townsend to troopers at the scene.