A Seattle jogger was left bloodied and bruised after using self-defense tactics she learned only three weeks ago to fend off a bathroom attacker.

Kelly Herron scratched, clawed, kicked and screamed to fight off Gary Steiner, 40, at a Golden Gardens Park restroom on Sunday afternoon.

The 36-year-old was training for a marathon when she stopped to use the bathroom and felt Steiner, a registered sex offender, sneak up behind her while she was drying her hands and attacked her, Seattle police said.

Herron said she began to fight back, yelling out 'not today m***** f*****' and managed to escape from Steiner's grasp and trapped the homeless man in the restroom until police arrived.

The jogger shared a photo on Instagram of injuries from her 'biggest running nightmare' but credited her safety to a self-defense class she took three weeks earlier and said: 'My face is stitched, my body is bruised, but my spirit is intact.'

Kelly Herron, 36, used self-defense to fend off a brutal assault from Gary Steiner, a registered homeless sex offender, at Golden Gardens Park's public restroom in Seattle on Sunday

Herron (left) was training for a marathon when she stopped to use a bathroom and was drying her hands when Steiner (right), 40, crept up behind her and attacked her. Steiner was convicted in Arizona for sexually assaulting several women in 1999

In the post that has been liked more than 15,000 times, she added: 'I stopped to use the restroom and was assaulted by a man hiding in a stall.

'I fought for my life screaming ("Not today, M**F***r!"), clawing his face, punching back, and desperately trying to escape his grip - never giving up. I was able to lock him in the bathroom until police arrived.

'Thankfully I just took a self-defense class offered at my work and utilized all of it.'

She added to Kiro 7: 'I’m really grateful I survived. I was screaming at him... being loud and not afraid. I mean you are afraid, but letting him know you are not taking me down today. You are not going to win this fight.

'That was the only thing that was motivating me ... I cannot be raped by this guy in this place.'

She scratched, clawed, kicked and screamed to fight off Steiner, using self-defense tactics she had learned just three weeks beforehand. Herron said: 'I’m really grateful I survived'

Steiner was taken by police shortly after Herron escaped and was helped by a witness who heard her screams and called officials.

She told police 'she felt like she was going to be raped' and Steiner was charged on Wednesday with attempted second-degree rape and second-degree assault with sexual motivation, according to The Seattle Times.

Police said Steiner confessed that while he was waiting in the bathroom, two other women entered the space but he didn't attack them.

But when Herron was drying her hands, he had worked up the nerve to approach her, knock her down and repeatedly punch her in the face in an attempted rape, according to police.

Pictured: The restroom at Golden Gardens Park where Herron said she was attacked

The charging documents continued that Steiner told police that he wanted them to kill him and an officer wrote: 'The defendant represents a severe danger to the community.

'His predatory attack on a female in the middle of the day represents a brazen willingness to assault without concern for getting caught.'

The paper reported that the man was convicted in Arizona for sexually assaulting several women in 1999, indecent exposure in 2008 and convicted of criminal mischief with a deadly weapon in Clark County, Washington, in 2015.