Nicholas Hansen of Farmingville is accused of opening fire on police officers at a gas station near a Long Island Expressway exit ramp on Thursday night. He survived and was expected to be arraigned on weapons, drugs and attempted murder charges at a later date.
The name of his attorney was not immediately known.
Prosecutors say Hansen was struck four times during the brief exchange of gunfire. No officers were injured.
The shooting occured moments after Hansen allegedly tried to sell undercover officers four ounces of cocaine.