Martinsburg City Police said the 23-year-old woman, who was four weeks pregnant, was walking in the 500 block of West King Street when a man approached her and began arguing about a comment she had made about him.
After a verbal confrontation, the woman told police her attacker pulled out a knife, held it to her back and ordered her to walk to an abandoned house in the 400 block of King Street.
She did as directed, police said, and both climbed into the house through a window.
While inside, the woman was grabbed by the hair, forced to undress and participate in sexual acts, police said.
Feigning the need to go to the bathroom, the naked woman dove through a window to escape, police said. She went to a friend's home, who gave her clothes and took her to the 7-Eleven on Winchester Avenue to call police and an ambulance, police said.
Gray has denied the charges in statements to police, who found out he had been charged with rape, theft, arson and several other felonies in Washington, D.C., according to court records.
The outcome of those cases was not included in court documents.