Police say a man is under guard in a Sydney hospital after being shot in the foot by his own gun.

Officers were called to reports of a shed fire at a property on Watt Street in Leumeah just after 6:30pm (AEDT) yesterday.

They arrived to find a burning shed and a man being restrained by several members of the public.

Two officers took a backpack off the 21-year-old before handcuffing and formally arresting him.

Police say as the man was being led to a nearby police van the backpack was dropped, causing a gun hidden inside to go off.

They say the bullet hit the man in the foot.

He was taken to Liverpool Hospital, where he remains under police guard awaiting surgery.