Biogas slurry is the liquid part of anaerobic fermentation of excrements from breeding industries. It is rich in organic matters, nitrogen, phosphorus, potassium, and other nutrients. However, biogas slurry is an environmental pollution source if it is discharged without proper treatment. To recover the nutrients and remove Suspended Solids (SS) and trace heavy metals in the biogas slurry, a membrane filtration system was designed in this work. Herein, Ceramic Membrane (CM) was applied for pretreatment because of its large membrane flux, strong anti-pollution ability and high chemical stability features. The key parameters that affect the performance of the membrane filtration system, such as membrane pore size, biogas slurry temperature, membrane surface velocity and Volume Reduction Factor (VRF), were investigated. The effects of pretreatment were studied via analyzing the membrane flux, Chemical Oxygen Demand (COD), turbidity, ammonia nitrogen, and the content of heavy metals under different conditions. The results showed that the membrane flux could reach 250 L/ (m² ·h) for 50 nm CM, which was 75 L/ (m² ·h) higher than that of 20 nm CM. However, in order to achieve high permeate water quality and heavy metal removal efficiency, ultrafiltration by 20 nm pore size CM was selected for pretreatment. The membrane flux increased from 165 to 275 L/ (m² ·h) upon increasing liquid temperature from 15 to 40 °C. With the increase of membrane surface velocity, the membrane flux increased gradually, but the increasing rate decreased. The membrane flux could reach 175 L/ (m² ·h) under the membrane surface velocity of 3.0 m/s.When the concentration rate increased, the membrane fluxes showed a downward trend of first fast and then slow. The maximum VRF of 20 nm pore CM could reach above 10, and the corresponding membrane flux was 62.6 L/ (m2 ·h). The pretreatment of biogas slurry by CM filtration had the optimal economy, when the frequency converter operated in the range of 40-45 Hz. The removal efficiency of turbidity by 20, 100 and 1 000 nm pore CMs was 99.77%, 83.91% and 81.87%, respectively. And there was no significant difference on the COD removal between 20 nm and 100 nm, which was 15.97% and 13.12%, respectively. There was almost no retention of ammonia nitrogen for all CMs. The removal rate of Ca, Mg, K, P by 20 nm CM was 14.7%, 66.3%, 3.9% and 32.9% respectively. The retention rate of Cu, Zn, Pb, Fe and Mn in biogas slurry by 20 nm CM was 96.0%, 95.5%, 100%, 86.5% and 76.0%, respectively. However the removal efficiency of Cr was quite low owing to its anionic state in biogas slurry. To draw a conclusion, pretreatment of biogas slurry by ultrafiltration using 20 nm CM could effectively remove SS and heavy metals, and retain majority of the dissolved organic and inorganic nutrients in biogas slurry. After pretreatment by ultrafiltration, nanofiltration(NF) or reverse osmosis(RO) could be used to concentrate the dissolved nutrients including organic matters, nitrogen, phosphorus, and potassium. This study provides a useful reference for the harmless treatment and resource utilization of swine wastewater and biogas slurry. It is anticipated that membrane concentrate system could render versatile applications for biogas slurry. [ABSTRACT FROM AUTHOR]