"The woman was unaware that a man followed her inside," police wrote in a press statement Tuesday.
As the woman came out of a stall, the man attacked the woman, hitting and choking her and pulling her hair, police said. The man smashed her head into the ground, and the woman lost consciousness, police wrote in jail documents. The man raped the woman, at which point a restaurant employee and a friend of the woman walked in on the attack, police wrote.
The man pulled up his pants and fled, police wrote.
"The victim ..., at great risk to herself, actively fought with this suspect throughout the entire assault," police wrote. "The victim was able to scratch the suspect multiple times, and she also grabbed a jacket the suspect had been carrying."
The jacket helped to identify Martinez as the suspect, police wrote. They arrested him about 1 p.m. as he was leaving the state driver's license office in West Valley City.
He was booked at the Salt Lake County jail.
The woman suffered multiple strikes to the face and head in the course of the attack, said West Valley City police Sgt. Jason Hauer.
"I'm told she's doing amazingly well considering the circumstances," Hauer said. "We wish her well in the recovery process."
Martinez was charged earlier this month with third-degree felony forgery and misdemeanor theft by deception. Police allege he approached a man July 18 at Zion's Bank at 3600 W. 3500 South and claimed he couldn't cash an $800 check because he'd lost his ID. The man agreed to give Martinez the cash only to find out the check was fraudulent, police wrote.