Treponema pallidum, herpes simplex virus types 1 or 2 (HSV-1/2) and Haemophilus ducreyi are sexually transmitted pathogens that can cause genital, anal and oropharyngeal ulcers. Laboratory evaluation of these pathogens in ulcers requires different types of specimens and tests, increasing the risk of improper specimen handling and time lapse until analysis. We sought to develop a new real-time PCR (TP-HD-HSV1/2 PCR) to facilitate the detection of T. pallidum, HSV-1/2 and H. ducreyi in ulcers. The TP-HD-HSV1/2 PCR was tested (i) in a retrospective study on 193 specimens of various clinical origin and (ii) in a prospective study on 36 patients with genital, anal or oropharyngeal ulcers (ClinicalTrials.gov # NCT01688258). The results of the TP-HD-HSV1/2 PCR were compared with standard diagnostic methods (T. pallidum: serology, dark field microscopy; HSV-1/2: PCR; H. ducreyi: cultivation). Sensitivity and specificity of the TP-HD-HSV1/2 PCR for T. pallidum were both 100%, for HSV-1 100% and 98%, and for HSV-2 100% and 98%, respectively. T. pallidum and HSV-1/2 were detected in 53% and 22% of patients in the prospective study; H. ducreyi was not detected. In the prospective study, 5/19 (26%) specimens were true positive for T. pallidum in the TP-HD-HSV1/2 PCR but non-reactive in the VDRL. The TP-HD-HSV1/2 PCR is sensitive and specific for the detection of T. pallidum and HSV-1/2 in routine clinical practice and it appears superior to serology in early T. pallidum infections.