Hepatocellular carcinoma (HCC) is the most common primary liver cancer and has a poor prognosis. Periodontitis, or tooth loss, is considered to be related to hepatocarcinogenesis and its poor prognosis. This study aimed to explore potential associations and cross-talk mechanisms between periodontitis and HCC. Periodontitis and HCC microarray datasets were acquired from the Gene Expression Omnibus (GEO) database and were analyzed to obtain differentially expressed (DE) lncRNAs, miRNAs and mRNAs. Functional enrichment analysis was used to detect the functions of these mRNAs. Then, a ceRNA network of periodontitis-related HCC was constructed. Least absolute shrinkage and selection operator (LASSO) regression, random forest algorithm, and support vector machine-recursive feature elimination (SVM-RFE) were performed to explore the diagnostic significance of mRNAs in periodontitis-related HCC. Cox regression analyses were conducted to screen mRNAs with prognostic significance in HCC. Quantitative real-time PCR (qRT-PCR) and immunohistochemistry (IHC) were conducted to validate the expression of these mRNAs in HCC tissues. A ceRNA network was constructed. Functional enrichment analysis indicated that the network is associated with immune and inflammatory responses, the cell cycle and liver metabolic function. LASSO, random forest algorithm and SVM-RFE showed the diagnostic significance of DE mRNAs in HCC. Cox regression analyses revealed that MSH2, GRAMD1C and CTHRC1 have prognostic significance for HCC, and qRT-PCR and IHC validated this finding. Periodontitis may affect the occurrence of HCC by changing the immune and inflammatory response, the cell cycle and liver metabolic function. MSH2, GRAMD1C and CTHRC1 are potential prognostic biomarkers for HCC.