Desperate to get away from her mother’s ex-boyfriend as he attacked her, a 12-year-old South St. Paul girl fought him off and turned to her iPod and Facebook to seek help, authorities said.

Her quick thinking got a message to her mother, who contacted South St. Paul police. Within hours, 42-year-old Raymond Ernest Cesmat was behind bars. The Dakota County Attorney’s office charged him Wednesday with two counts of criminal sexual conduct in the first degree, felonies punishable by up to 30 years in prison.

Cesmat, who has a sizable criminal history, is being held at the Dakota County Jail in Hastings in lieu of $175,000 bail.

The incident unfolded early Saturday morning while the girl’s mother was out of the house, according to the criminal complaint. The mom was no longer dating Cesmat but he continued to live with them.

The girl told police that Cesmat had taken away her cell phone away when she went to bed, telling her he did not want her texting all night. He also told her to leave her door open, the complaint said.

She told police she had woken up to find him standing in her room before, and felt that it was about to happen again. “The juvenile stated that she just knew that he would come back to her room later,” the complaint state.

He later walked in naked and tried to pull off her pants, she said, but she kicked him away and screamed, according to the complaint. When he left, she got out her iPod and found an acquaintance on the social networking website Facebook.com. She begged her friend to contact her mother and tell her to come pick her up.

As she was sending the message, Cesmat went back to her room and sexually assaulted the girl, the complaint said. She fought back, scratching him hard enough to draw blood. Before he left her room, he allegedly looked at her and said: “I will use you whenever I want.”

The complaint states she then pushed her dresser in front of her door, climbed out a window and ran to a payphone to call her mother, who had received the message from the girl’s Facebook friend and was already on her way. The two met at a nearby school. When police arrived, the girl was still crying and upset.

Police found Cesmat at home and noticed scratches on his stomach and arms, as well as a bloody cut on his right hand, according to the complaint. He told them his daughter had run away and he had cut his finger looking for her.

They found blood on the girl’s dresser and on her bedspread and pillow, as well as her shirt, the complaint said.

Cesmat was arrested but denied sexually assaulting the girl, according to the complaint. He said he he’d spent the night at two bars and at a friend’s house and hadn’t seen the girl when he arrived home shortly before 5 a.m.

Police located Cesmat’s friend, who guessed he’d left her residence closer to 3:15 a.m. A text message on her phone from 3:27 a.m. indicated he had made it home, the complaint said.

His criminal history includes multiple convictions for theft and issuing worthless checks, as well as driving under the influence of alcohol and driving with a canceled driver’s license, according to court records.

His next court appearance is August 16.

Frederick Melo can be reached at 651-228-2172.