A 46-year-old man has been charged with attempting to sexually assault a 12-year-old boy at Sydney's Bass Hill Plaza shopping mall over the weekend.

On Saturday evening, the young boy walked into the men's bathrooms and noticed a man standing in one of the cubicles with the door open.

He immediately attempted to leave the toilets but the man quickly came out from the cubicle, grabbed the boy by the waist and pulled him back, a NSW Police spokeswoman said.

Police say the man hit the boy across the head while attempting to pull him into the cubicle.

As this was happening, two men walked into the bathroom, giving the boy enough time to break free and run out.

The incident was then reported to police, who went to the shopping centre and examined CCTV footage, which they then released to the public in an attempt to find the man.

Following the post (which has now been deleted from the NSW Police Facebook), a man went into Bankstown Police Station and was arrested and charged with assault with intent to have sexual intercourse with children between the ages of 10 and 16.

He was refused police bail and is due to appear in Bankstown Local Court today.