HIV associated neuropathic pain (HANP) is a common complication of AIDS. Intrathecal injection of recombinant HIV-1 gp120 in mice is a well-known model. Previous RNA sequencing revealed spinal TLR2 acts as a differentially expressed gene in HANP mice. The spinal TLR2 is involved in HANP, but its role and underlying mechanism remains unclear. In this study the transcription, expression and distribution characteristics of TLR2 in the spinal cord of HANP male mice have been analyzed by qRT-PCR, Western blotting, and immunofluorescent staining. We found that TLR2 expression was upregulated in the spinal dorsal horn and mainly distributed in microglial cells, and blocking TLR2 relieved pain of HANP mice. Following stimulation by gp120 microglial cells upregulate TLR2 expression and become activated. The activation stimulates their differentiation into the M1 type, increasing IL-1β and TNF-α expression while inhibiting IL-10 expression. Silencing the Tlr2 gene slows down the activation, polarization, and secretion of pro-inflammatory factors in microglial cells induced by gp120, and enhances the expression of anti-inflammatory factors. Further analysis of the impact of gp120 on downstream signaling pathways of TLR2 in microglial cells, including NF-κB, MAPK (p38MAPK, ERK, and JNK) and PI3K/AKT, revealed that TLR2-NF-κB signaling plays a crucial role in the activation and polarization of microglial cells by gp120. Activation of NF-κB signaling aggravates pain in HANP mice, while blocking it lightens pain. This data indicates that gp120, through the TLR2-NF-κB signaling, activates spinal microglial cells, promotes the secretion of inflammatory cytokines, leading to HANP. This provides new targets to develop drugs for HANP.