A young woman woke up in her Williamsburg apartment early Friday to find a stranger on top of her trying to rape her, police said.

The 25-year-old Brooklyn woman was asleep in her bed around 4:30 a.m. in her home near the corner of Grand Street and Union Avenue when she woke up to an unidentified man grabbing her mouth and pinning her down, cops said.

The woman was able to scream at some point, sending the would-be rapist running out the door, police said.

Police described the man as around 24 years old and 5 foot 7 with black hair. He was last seen wearing a black T-shirt and blue jeans.