The influence of membrane fouling on the retention of the trace organic contaminant sulfamethoxazole by a nanofiltration (NF) process was investigated. Organic fouling caused a severe flux decline possibly due to pore blocking and adsorption directly after the commencement of the fouling layer development. Such membrane-foulant interactions were absent for colloidal fouling, which resulted in a more gradual flux decline. Membrane charge played a significant role in the separation process of inorganic salts, where the retention was the highest in a caustic environment (high pH) due to more swollen membrane material caused by the higher negative charge on the membrane. Organic fouling and a combination of colloidal and organic fouling led to a significant increase in the membrane negative charge. The influence of membrane fouling on solute retention was dependent on the fouling behaviour and the physicochemical properties of the model foulants, where the model foulants probably contributed to an increase in the retention of charged solutes due to enhanced electrostatic interactions. Organic fouling caused an increase in the retention of inorganic salts and sulfamethoxazole due to pore blocking. In contrast, colloidal fouling caused a decrease in the retention of inorganic salts due to cake-enhanced concentration polarisation. However, the presence of a colloidal fouling layer did not reduce the retention of sulfamethoxazole. A mixture of colloidal and organic matter improved the retention of inorganic salts. A similar conclusion can be inferred for sulfamethoxazole at pH 4 when the compound exists in a neutral form.