A 15-year-old boy has been charged after he was allegedly found carrying a pistol in his backpack at Central Railway Station in Sydney.

Undercover police officers stopped the boy for allegedly shoplifting at the station on Monday afternoon, but when they searched his backpack, they allegedly discovered the gun.

A gun was found in the bag of a 15-year-old boy at Sydney's Central Railway Station. Credit:Fiona Morris

Officers from the Police Transport Command were performing covert duties about 3.30pm as part of an operation targeting property offences around the station.

The officers allegedly saw a group of teenagers enter a shop on the concourse, and the 15-year-old boy allegedly stole a bottle of soft drink.