A man has been pulled over while riding a motorbike with a two-year-old boy in his arms.

Police officers say they noticed the motorbike in Heckenburg, south-west of Sydney, about 9:45pm (AEST) on Saturday.

They say the rider was not wearing a helmet, had no lights on and appeared to be carrying a bag in his arms.

When officers told him to pull over, it is alleged he rode up on the footpath, dropped the bike and ran off.

He was soon caught and what was first thought to be a bag turned out to be a toddler in his arms.

The boy was taken to hospital and is now with his mother.

The rider was released pending further questioning.

Police say they are investigating several offences including riding under the influence of alcohol, riding whilst disqualified, riding in a dangerous manner, and hindering police.