Jamie Devine has now appeared in court in connection with the matter.
The 41-year-old pled not guilty to a charge of engaging in a sexual activity at the school in the presence of a female.
Sheriff Ian Duguid QC released Devine, of Buchanness Drive, Boddam, on bail with a condition not to enter Kellie Pearl Way or approach or contact the female.
Devine said: “I’ll just not enter Ellon.”
A trial date was fixed for early next year, with a pre-trial hearing set for December.
A spokeswoman for Police Scotland said: “At around 1.55pm, police were called to a secondary school in Ellon by staff concerned by the behaviour of a man who had attempted to enter the grounds, and who was seen nearby acting inappropriately at a bus stop.
“A 41-year-old man has been arrested and is due to appear in Aberdeen Sheriff Court.”
Man in dock accused of sexual activity outside north-east school