A homeless man assaulted a police officer when she asked him for ID in Chelsea, police and sources said Wednesday.

The cop had asked 28-year-old Brian Thayer for his identification around 8:30 a.m. Tuesday when she spotted him blocking the staircase at a subway station near Seventh Avenue and West 34th Street.

Thayer allegedly told her he’s a police officer and then got up and walked away. When she tried to place him under arrest, he flailed his arms and allegedly refused to be handcuffed.

Then, when she tried to place him in the cop car, he kicked her repeatedly in the knees and stomach, police sources said.

He continued his assault on her later in the day, while he was in a jail cell, where he spat at her, the sources added.

She was taken to Lenox Hill HealthPlex for treatment.

Thayer was charged with assault, criminal impersonation, resisting arrest, obstruction of governmental administration and violation of local law, police said.