A man has been charged after he was allegedly found carrying a small pipe bomb hidden in a glasses case, which he planned to detonate in the harbour after having a "very bad day", police say.

Officers also allegedly found a gun, ammunition and a speargun when they searched Robert Day's Chester Hill home.

Mr Day, 33, was stopped by police who were doing random drug searches at the railway station about 7.40pm yesterday.

He was searched and the pipe bomb was found inside the case, police said.

Police said the explosive was secured and given to officers from the bomb squad, who declared it safe at a "secure location".