Cell-free (CF) massive multiple-input multiple-output (M-MIMO) technology plays a prominent role in the beyond fifth-generation (5G) networks. However, designing a high performance CF M-MIMO detector is a challenging task due to the presence of pilot contamination which appears when the number of pilot sequences is smaller than the number of users. This work proposes a CF M-MIMO detector referred to as CF expectation propagation (CF-EP) that incorporates the pilot contamination when calculating the posterior belief. The simulation results show that the proposed detector achieves significant improvements in terms of the bit-error rate and sum spectral efficiency performances as compared to the ones of the state-of-the-art CF detectors.