This study investigated via polymerase chain reaction (PCR) three main serotypes (A1, A2, and A6) and nine virulence-associated genes in 71 ovine and caprine Mannheimia haemolytica isolates obtained from lungs (n = 349) with pneumonic lesions from a slaughterhouse in Iran. The lung specimens were collected from sheep (n = 197) and goats (n = 152) between December 2018 and January 2020. A total of 71 M. haemolytica isolates were identified in sheep (37/197; 18.8%) and goat (34/152; 22.4%) pneumonic lungs. Serotypes A2 (30/71; 42.3%) and A6 (29/71; 40.9%) were the most frequently detected, whereas the A1 serotype was detected with a frequency of less than 10% (7/71; 9.9%) and five isolates remained untypable. The virulence genes lkt, pomA, and nanH were present in all the isolates. The detection rates for the remaining virulence-associated genes were: gcp (95.8%), lpsA (93%), fhaC (90%), irp (70.4%), hf (57.7%), and sodC (21%). The sodC gene was exclusively detected among A2 isolates (50%), while the irp gene was more prevalent among A2 isolates and the hf gene among A1 and A6 isolates. These data may be useful for the typing of isolates in epidemiological studies. This study provides information about the main serotypes and the prevalence of virulence-associated genes among M. haemolytica ovine and caprine isolates in Iran.