This study aimed to elucidate the relationship of type 2 diabetes, other known risk factors, and primary hepatocellular carcinoma (HCC) in countries with a high prevalence of hepatitis infection. We followed a prospective cohort of 54,979 subjects who participated in the Keelung Community-Based Integrated Screening program between 1999 and 2002. A total of 5,732 subjects with type 2 diabetes cases were identified at enrollment on the basis of fasting blood glucose level, and a total of 138 confirmed HCC cases were identified either through two-stage liver cancer screening or linkage with the National Cancer Registry. The independent effect of type 2 diabetes on the incidence of HCC and the interaction between type 2 diabetes and hepatitis infection or lipids profile were assessed using the Cox proportional hazards regression model. After controlling for age, sex, hepatitis B virus (HBV), hepatitis C virus (HCV), smoking, and alcohol consumption, the association between type 2 diabetes and incidence of HCC (excluding 33 prevalent cases identified at enrollment) was modified by HCV status and cholesterol level. The associations were only statistically significant (adjusted hazard ratio [HR] = 2.08 [1.03-4.18]) for being HCV negative and for having hypercholesterolemia (adjusted HR = 2.81 [1.20-6.55]). These statistically significant findings remained even excluding cases of diabetes newly diagnosed at enrollment. In conclusion, in an area with a high prevalence of hepatitis virus infection, type 2 diabetes increases the risk of developing HCC in those who are HCV negative or have a high level of total cholesterol.