An ex-security guard wanted a sexual relationship with Ashley Benson because that's just the way God wanted it ... according to court docs Benson filed to keep the guy away from her.
The "Pretty Little Liars" star got a temporary restraining order Wednesday against James Gorton Jr. -- a married, 49-year-old who was recently fired from his job as a guard on the Warner Bros. lot where PLL is filmed.
Gorton has told people he has a relationship with Benson ... that he has sexual feelings for her ... and that God instructed him to pursue her romantically ... according to court docs obtained by TMZ.
According to studio security officials ... Gorton told them he felt a special connection with Benson after she happened to glance at him one day, and believed she and others were silently communicating messages to him.
Gorton has since been fired, but Benson says she fears he may still try to track her down at her home.
Gorton is now required to stay at least 100 yards away.