The aim of the present study was to determine whether the echotextural features of the mammary gland parenchyma in buffaloes during lactation at different somatic cell levels could be used to diagnose mastitis. This study was divided into two parts. In the first experiment, experimental buffaloes (n = 65) with somatic cell counts (SCC) tests (n = 94) in different seasons, including spring (n = 22), summer (n = 24), autumn (n = 37), and winter (n = 11), were used to obtain ultrasonic variables for each quarter of mammary gland that could best explain the corresponding somatic cell level. In the second part of the study, the first part's experimental results were verified by subjecting at least one-quarter udder of eight buffaloes to ultrasonography seven times during mid-July to mid-August for obtaining ultrasonic values at different somatic cell levels. The echo textural characteristics [mean numerical pixel values (NPVs) and pixel heterogeneity (pixel standard deviation, PSD)] were evaluated using 16 ultrasonographic images of each buffalo with Image ProPlus software. The effects of SCC, days in milk (DIM), scanning order (SO), season, as well as the scanning plane and udder quarter (SP + UQ) on both the PSD and NPVs of the mammary gland were significant (p < 0.05). The correlation coefficient between pre-milking sagittal PSD and somatic cell score (SCS) was the highest (r = 0.4224, p < 0.0001) with fitted linear model: y = 0.19445x (dependent variable: SCS, independent variables: pre-milking sagittal PSD; R2 = 0.84, p < 0.0001). In addition, SCC and ultrasonic of udder quarter were followed for 1 month, confirming that pre-milking sagittal PSD of mammary gland value could explain the SCC variation in milk. The current study demonstrated that the ultrasonographic examination of the udder could be one of the complementary tools for diagnosing subclinical mastitis in buffaloes.