Hepatic ischemia/reperfusion injury (IRI) remains a severe threat during liver surgery and transplantation, accounting for unfavorable clinical outcomes. Modafinil (MOD), a wakefulness‐inducing compound, is increasingly disclosed to protect against IRI. However, the specific literatures covering the association between MOD and hepatic IRI are few. Here, this paper is committed to unraveling the role and response mechanism of MOD in hepatic IRI. After the establishment of hepatic IRI mice model and cell model, relevant assay kits measured the concentrations of biochemical indicators of hepatotoxicity and hematoxylin and eosin staining estimated liver morphology. Enzyme‐linked immunosorbent assay, reverse‐transcription quantitative polymerase chain reaction, and western blot evaluated inflammatory levels. Terminal‐deoxynucleoitidyl transferase‐mediated nick end labeling assay and western blot appraised apoptosis. Western blot also analyzed the expression of Toll‐like receptor 9 (TLR9)/myeloid differentiation primary response gene 88 (MyD88)/p38 signaling‐associated proteins. Cell counting kit‐8 method judged cell viability. MOD was discovered to mitigate liver dysfunction and morphological damage, inflammatory response, apoptosis in vivo and improve cell viability, suppress inflammatory response and apoptosis in vitro. In addition, MOD inactivated TLR9/Myd88/p38 signaling both in vitro and in vivo. Further, TLR9 elevation reversed the inhibitory role of MOD in inflammatory response and cell apoptosis in vitro. Anyway, MOD blocked TLR9/Myd88/p38 signaling to exhibit anti‐inflammatory and anti‐apoptotic properties in hepatic IRI.