About 4.30pm on Monday Mr Wanstall drove to a block of units in Westmead where he was expecting to meet the girl, police said.
Instead, plain clothes detectives pounced and arrested the 47-year-old maths teacher on the street.
He was handcuffed and put into the back of a police wagon.
Officers executed a search warrant at a home in Rouse Hill, where detectives seized several items including a laptop and an electronic storage device.
Mr Wanstall was taken to Granville police station and charged with using a carriage service to procure a child under 16 for sexual activity, and using a carriage service to transmit child abuse material.
Detective Acting Superintendent Chris Goddard, commander of the Child Abuse and Sex Crimes Squad, told radio station 2GB the police sting caught the alleged offender by surprise.
“These people turn up thinking that they’re meeting a 14-year-old girl and a couple of my detectives hop out of cars and confront him. I could imagine shock, surprise,” Mr Goddard said.
“Probably their whole life flashes in front of them, one would imagine.”
Mr Goddard said police would work with the NSW Education Department to investigate whether any students at the school were harmed.
A spokesman for the NSW Education Department declined to comment, referring questions to NSW Police.
Mr Wanstall was refused bail to appear at Fairfield Local Court on Tuesday.
Strike Force Trawler is an ongoing investigation by the child exploitation internet unit into the sexual abuse and exploitation of children facilitated through the internet and related telecommunications devices.
Josh Dye is a news reporter with The Sydney Morning Herald.