Mohamad Zreika allegedly pointed a gun at commuters waiting at Lidcombe train station before boarding a train to Bankstown at 5.30pm yesterday.
He was taken to hospital for a psychiatric examination.
He was refused bail to appear at Bail Division Local Court 7 today.
NEVER MISS A STORY: Be the first to receive your latest news and exclusive stories by following us on all platforms.