Primary liver cancer is a rising cause of cancer deaths in the US. Although immunotherapy with immune checkpoint inhibitors induces a potent response in a subset of patients, response rates vary among individuals. Predicting which patients will respond to immune checkpoint inhibitors is of great interest in the field. In a retrospective arm of the National Cancer Institute Cancers of the Liver: Accelerating Research of Immunotherapy by a Transdisciplinary Network (NCI-CLARITY) study, we use archived formalin-fixed, paraffin-embedded samples to profile the transcriptome and genomic alterations among 86 hepatocellular carcinoma and cholangiocarcinoma patients prior to and following immune checkpoint inhibitor treatment. Using supervised and unsupervised approaches, we identify stable molecular subtypes linked to overall survival and distinguished by two axes of aggressive tumor biology and microenvironmental features. Moreover, molecular responses to immune checkpoint inhibitor treatment differ between subtypes. Thus, patients with heterogeneous liver cancer may be stratified by molecular status indicative of treatment response to immune checkpoint inhibitors