The role of the protozoan parasite Toxoplasma gondii in the pathogenesis of liver disease has recently gained much interest. The aim of this study was to determine the prevalence and risk factors associated with T. gondii infection in patients with liver disease from three cities in Shandong and Henan provinces, China. A case–control study was conducted from December 2014 to November 2015 and included 1142 patients with liver disease and 1142 healthy controls. Serum samples were collected from all individuals and were examined with enzyme-linked immunosorbent assay for the presence of anti-T. gondii IgG and IgM antibodies. Information on the demographics, clinical, and lifestyle characteristics of the participants was collected from the medical records and by the use of a questionnaire. The prevalence of anti-T. gondii IgG was 19·7% in patients with liver disease compared with 12·17% in the controls. Only 13 patients had anti-T. gondii IgM antibodies compared with 12 control individuals (1·14% vs. 1·05%, respectively). The highest seroprevalence was detected in patients with liver cancer (22·13%), followed by hepatitis patients (20·86%), liver cirrhosis patients (20·42%), and steatosis patients (20%). Multivariate logistic regression analysis indicated that consumption of raw meat (odds ratio (OR) = 1·32; 95% confidence interval (CI) 1·01–1·71; P = 0·03) and source of drinking water from wells (OR = 1·56; 95% CI 1·08–2·27; P = 0·01) were independent risk factors for T. gondii infection in liver disease patients. These findings indicate that T. gondii infection is more likely to be present in patients with liver disease. Therefore, efforts should be directed toward health education of populations at high risk of T. gondii infection and measures should be taken to protect vulnerable patients with liver disease.