A 21-year-old woman fought off a rape attempt by a fellow student who burst into her private study room at the Hunter College library, sources told The Post on Wednesday.

The alleged victim was reading alone at around 7:15 p.m. Monday in a room she had reserved when the man came in and asked for directions to the bathroom.

When she looked up, he exposed himself and then pounced on her, but she was able to push him off, the sources said. When she snapped pictures of him as he fled, he charged back, bit her, took her phone and ran off.

A suspect, Kareem Royes, 25 — was arrested Wednesday at 3:30 a.m. at his Bronx home — because he reportedly used his own student ID to enter the Upper East Side library and was captured on library video, the sources said.

Royes, a married father of a 4-year-old girl and a licensed taxi driver with a prior arrest for exposing himself on the subway, was held in lieu of $60,000 bond on charges of second-degree robbery and public lewdness, police said.

Hunter has suspended him pending an investigation.