Gastrodia elata Blume, also called Tian Ma (TM), has been used to treat stroke for centuries. However, its effects on inflammation in acute cerebral ischemic injury and underlying mechanisms involved in microglial polarization remain unknown. The present study explored the effects of the TM extract on the modulation of microglial M1/M2 polarization 2days after transient cerebral ischemia. Male Sprague Dawley rats were intracerebroventricularly administered with 1% dimethyl sulfoxide 25min before cerebral ischemia and subsequently intraperitoneally administered 0.25g/kg (DO + TM-0.25g), 0.5g/kg (DO + TM-0.5g), or 1g/kg (DO + TM-1g) of the TM extract after cerebral ischemia onset. DO + TM-0.5g and DO + TM-1 g treatments downregulated the following: phospho-c-Jun N-terminal kinase (p-JNK)/JNK, tumor necrosis factor (TNF) receptor-associated factor 3 (TRAF3), TRAF3-interacting JNK-activating modulator (T3JAM), p-nuclear factor-kappa B p65 (p-NF-κB p65)/NF-κB p65, ionized calcium-binding adapter molecule 1 (Iba1), CD86, TNF-α, interleukin (IL)-1β, and IL-6 expression and toll-like receptor 4 (TLR4)/Iba1, CD86/Iba1, and p-NF-κB p65/Iba1 coexpression. These treatments also upregulated IL-10, nerve growth factor, and vascular endothelial growth factor A expression and YM-1/2/Iba1 and IL-10/neuronal nuclei coexpression in the cortical ischemic rim. The JNK inhibitor SP600125 exerted similar treatment effects as the DO + TM-0.5g and DO + TM-1 g treatments. DO + TM-0.5g and DO + TM-1 g/kg treatments attenuate cerebral infarction by inhibiting JNK-mediated signaling. TM likely exerts the neuroprotective effects of promoting M1 to M2 microglial polarization by inhibiting JNK/TLR4/T3JAM/NF-κB-mediated signaling in the cortical ischemic rim 2days after transient cerebral ischemia.