A 21-year-old woman was hit in the head with a rubber mallet while getting on the No. 6 train on the Upper East Side, police said Wednesday.

The woman was buying a MetroCard at the 96th Street station at about 9:45 p.m. Tuesday when a man came up and tried to talk to her, police said. She ignored the man and headed toward the southbound platform.

But a woman followed her, police said, and spit on her. The woman then took out a black rubber mallet from her pink purse and hit the victim over the head with it.

The victim then got on the train, heading to 51st Street, but realized she was bleeding from the back of her head.

Police said she was taken to Metropolitan Hospital Center for treatment.

The suspect is described as a woman in her 20s, about 5-feet-8-inches and 135 pounds.