A Japanese man who turned up at a school dressed in a girl's uniform and a long wig was arrested for trespassing, police said.

Tetsunori Nanpei, 39, put on the uniform he had bought over the internet and took a walk near the high school in Saitama, north of Tokyo, on Wednesday.

Students standing outside the school gates caught sight of him and started screaming, local papers reported, at which point Nanpei rushed on to the school grounds hoping to blend in with the crowds of teenagers.

When pupils in the school began screaming the man fled, losing his wig in the process. A school clerk pursued him and stopped him at a nearby riverbank.

Police confirmed the man's arrest but gave no further details.