Foreign matter defect introduced during lithium-ion battery manufacturing process is one of the main reasons for battery thermal runaway. Therefore, reliable detection of the foreign matter defect is needed for safe and long-term operation of lithium-ion batteries. It is favored to detect the defective battery during the battery manufacturing process before the battery is put into use. In this study, the defects are implanted into batteries on a real battery pilot manufacturing line. Data of defective batteries and thousands of normal batteries are collected for data analyses and algorithm development. Feature selection is conducted with feature importance analysis using the random forest method and out-of-bag error calculation. Local outlier factor method is used for defect detection with the selected features as input. The proposed defect detection algorithm achieves high detection rate and low false alarm rate which has the potential to be deployed on the manufacturing execution system to further enhance screening ability of defective batteries and improve battery safety.