Bartonella are gram-negative intracellular bacteria; certain species of Bartonella can cause diseases in mammals and humans. Ticks play a major role in the transmission of Bartonella. Xinjiang is the largest province in China according to land area and has one-third of the tick species in China; the infection rate of Bartonella in ticks in the Xinjiang border areas has not been studied in detail. Therefore, this study investigated tick infections by Bartonella in Xinjiang border areas, and the purpose of the study was to fill in gaps in information regarding the genetic diversity of tick infections by Bartonella in Xinjiang. We tested 1,549 tick samples from domestic animals (sheep and cattle) for Bartonella using ribC-PCR. Positive samples from the ribC-PCR assay for Bartonella spp. were further subjected to PCR assays targeting the ITS, rpoB and gltA genes followed by phylogenetic analyses. Bartonella DNA was detected in 2.19% (34/1,549) of tick samples, and the ITS, rpoB and gltA genes of ribC gene-positive samples were amplified to identify nine samples of Bartonella melophagi. In this study, molecular analysis was used to assess the presence and genetic diversity of B. melophagi in ticks collected from sheep and cattle from Xinjiang, China. This study provides new information on the presence and identity of B. melophagi in ticks from sheep and cattle.