Because of the diversity of the clinical and laboratory manifestations, the diagnosis of autoimmune liver disease (AILD) remains a challenge in clinical practice. The value of metabolomics has been studied in the diagnosis of many diseases. The present study aimed to determine whether the metabolic profiles, based on ultraperformance liquid chromatography-mass spectrometry (UPLC-MS), differed between autoimmune hepatitis (AIH) and primary biliary cirrhosis (PBC), to identify specific metabolomic markers, and to establish a model for the diagnosis of AIH and PBC. Serum samples were collected from 20 patients with PBC, 19 patients with AIH, and 25 healthy individuals. UPLC-MS data of the samples were analyzed using principal component analysis, partial least squares discrimination analysis and orthogonal partial least squares discrimination analysis. The partial least squares discrimination analysis model (R2Y=0.991, Q2=0.943) was established between the AIH and PBC groups and exhibited both sensitivity and specificity of 100%. Five groups of biomarkers were identified, including bile acids, free fatty acids, phosphatidylcholines, lysolecithins and sphingomyelin. Bile acids significantly increased in the AIH and PBC groups compared with the healthy control group. The other biomarkers decreased in the AIH and PBC groups compared with those in the healthy control group. In addition, the biomarkers were downregulated in the AIH group compared with the PBC group. The biomarkers identified revealed the pathophysiological changes in AILD and helped to discriminate between AIH and PBC. The predictability of this method suggests its potential application in the diagnosis of AILD.