Mohamad Zreika allegedly pointed a pistol at commuters waiting at Lidcombe railway station, before boarding a train to Bankstown at 5.30pm yesterday.
He was taken to hospital for a mental health assessment.
He was refused bail to appear before Bail Division Local Court 7 today.
NEVER MISS A STORY: Get your breaking news and exclusive stories first by following us across all platforms.