Anaplasma (A.) ovis is the most important cause of anaplasmosis in small ruminants. The current study was planned to estimate the molecular prevalence, risk factors, and phylogenetic analysis of A. ovis infection in sheep and goats from different agro-climatic regions of Central and Southern Punjab, Pakistan. A total of 400 jugular blood samples were collected from asymptomatic goats (n = 200) and sheep (n = 200) from the Jhang and Dera Ghazi Khan districts from January 2021 to February, 2023. Two hundred blood samples were collected from each district. Ten union councils (UC) were randomly chosen from each district, and 20 samples were collected from each UC based on the multistage cluster sampling technique. The samples were analyzed with PCR targeting the major surface protein (msp4) gene of A. ovis. The overall molecular prevalence of anaplasmosis was 57.5%. The disease occurrence was higher in Dera Ghazi Khan (61.5%) than in the Jhang district (53.5%). Infection positivity was greater in goats (65.5%) than in sheep (49.5%). Multivariate logistic regression analysis indicated that host species [sheep; Odds Ratio (OR) = 3.212; p = 0.000, Confidence Interval (CI) = 1.968–5.242], age (adult; OR = 2.606; p = 0.003, CI = 1.398–4.858), and acaricide use (never; OR = 13.671; p = 0.000, CI = 6.414–26.283) were significantly higher risk for A. ovis in small ruminants (p< 0.05; OR > 1). The sequencing and phylogenetic analysis of four representative isolates in the current study (Genbank numbers; Goats: OQ302202, OQ302203; Sheep: OQ319592, OQ319593) revealed novel strains of A. ovis with 97–100% similarity from different countries. The msp4-based goat isolates showed greater genetic diversity, while sheep genotypes showed homology with isolates from Italy, Spain, Hungary, Cyprus, Spain, Iran, and China. The current surveillance study will help in devising prevention and control strategies regarding anaplasmosis in small ruminants. However, there is a need for further study on the clinicopathological and vector competence aspects of these genotypes.