In this study, the nanofiltration of cleaning-in-place (CIP) wastewater was studied using a two-step nanofiltration (NF) process. In the first step, the effects of operating parameters including pH, temperature, and transmembrane pressure on the membrane fouling were investigated using a loose NF membrane. Also, Taguchi method was applied in order to design the experiments and optimize the experimental results. The optimum conditions providing the lowest flux decline were estimated. L(9) (3(4)) orthogonal array for experimental planning and the smaller-the-better response category was selected to obtain optimum conditions. Analysis of variance (ANOVA) was used to determine the most significant parameters affecting the flux decline caused by membrane fouling. The optimum conditions were found as the second level of pH (7), first level of temperature (25 degrees C) and first level of transmembrane pressure (12 bar). Under these conditions, flux decline caused by membrane fouling was predicted as 24% that was within the range of confidence limit of the observed value of 20%. Transmembrane pressure was found to be the most important factor on the flux decline. The effect of pH on the membrane fouling was also investigated with scanning electron microscopy (SEM) and contact angle measurements. It was found that pore plugging was dominant at pH 4. In the first step of the treatment; 97% chemical oxygen demand (COD), 100% sulphate, 50% chloride and 38% conductivity removal was obtained under the optimized conditions. In the second step, the quality of permeate obtained from the first step was improved using a tight membrane at 20 and 30 bar. Even better rejections were achieved especially for chloride and conductivity in the second step at 30 bar. (C) 2009 Elsevier B.V. All rights reserved.