Theileria annulata is a tick-associated parasite that causes tropical theileriosis in livestock and is responsible for huge economic losses. Studies have been neglected on the effect of Theileria spp. on cattle in Khyber Pakhtunkhwa (KP), Pakistan. The present study was designed to determine the genetic diversity and assess the risk factors associated with Theileria infection in selected districts of KP. Information on the risk factors related to the Theileria infection was collected through a questionnaire. Blood samples were collected from symptomatic cattle from January 2019 to February 2020, identified morphologically through microscopic examination, and processed for molecular characterization using the 18S rRNA gene as a genetic marker. Of the 555 cattle examined (136, 24.5%) and (294, 53%) were found positive for Theileria spp. by microscopic examination and a PCR test, respectively. Based on the PCR test, the highest prevalence of infection was found in district Upper Dir (46/75, 61.3%), followed by Lower Dir (54/90, 60%); Malakand (51/88, 57.9%); Peshawar (40/80, 50%); and Charsadda (52/112, 46.4%), with the lowest in Bajaur (51/110, 46.34%). A BLAST analysis of the 18S rDNA sequences showed 99.5% identity with T. annulata. In a phylogenetic tree, the 18S rDNA sequence of T. annulata clustered with sequences from Pakistan, China, and Italy. A significant association was observed between the prevalence of infection and different host characteristics. The highest infection was found in adult cattle (216/360, 60%); females (218/377, 57.8%); and Holstein Friesian (120/180, 66.6%). Theileria infection was significantly associated with management practices. Higher infection rates were observed in free-grazing cattle (190/412, 42.2%); those kept in unhygienic conditions (246/405, 60.7%); cattle in combined farming systems (165/255, 64.8%); and those in congested stall systems (150/218, 68.8%). Seasonal patterns were found to be significantly associated with infection, and a higher infection rate was observed in summer (215/350, 61.4%) than in winter (79/205, 38.5%). Identified risk factors should be considered in designing practical control approaches to reduce the burden of Theileria infection. Large scale studies are required to explore the diversity of Theileria species in KP, Pakistan.