Chlamydia trachomatis infection is an important public health problem. Our objective was to assess the dynamics of the transmission of this infection, analysing the distribution of circulating ompA genotypes and multilocus sequence types of C. trachomatis in Spain as a function of clinical and epidemiological variables. During 2018 and 2019, we genetically characterized C. trachomatis in tertiary hospitals in six areas in Spain (Asturias, Barcelona, Gipuzkoa, Mallorca, Seville and Zaragoza), with a catchment population of 3.050 million people. Genotypes and sequence types were obtained using polymerase chain reaction techniques that amplify a fragment of the ompA gene, and five highly variable genes (hctB, CT058, CT144, CT172 and pbpB), respectively. Amplicons were sequenced and phylogenetic analysis was conducted. We obtained genotypes in 636/698 cases (91.1%). Overall and by area, genotype E was the most common (35%). Stratifying by sex, genotypes D and G were more common among men, and genotypes F and I among women (p < 0.05). Genotypes D, G and J were more common in men who have sex with men (MSM) than in men who have sex with women (MSW), in whom the most common genotypes were E and F. The diversity index was higher in sequence typing (0.981) than in genotyping (0.791), and the most common sequence types were ST52 and ST108 in MSM, and ST30, ST148, ST276 and ST327 in MSW. Differences in genotype distribution between geographical areas were attributable to differences in population characteristics. The transmission dynamics varied with sexual behaviour: the predominant genotypes and most frequent sequence types found in MSM were different to those detected in MSW and women.