Research has implicated endocannabinoids (eCBs) as significant regulators of neuroinflammation that may contribute to autism spectrum disorder (ASD). This study investigated the effect of the main eCBs, namely N-acylethanolamine (NAE) and 2-arachidonoylglycerol (2-AG), on ASD and their underlying mechanisms through in vivo and in vitro experiments. Results showed that elevating NAE or 2-AG ameliorated social deficits and restricted and repetitive behaviors and corrected neuropathological damage. Additionally, enhancing 2-AG protected valproic acid (VPA)-exposed rats against nerve damage by modulating abnormal neuroinflammation, as evidenced by the fact that 2-AG decreased microglial reactivity with reduced pro-inflammatory responses and increased anti-inflammatory responses. While, NAE only had a subtle effect on regulating neuroinflammation. Collectively, these findings suggested that elevating both NAE and 2-AG could improve ASD symptoms. Elevating 2-AG may play a neuroprotective role by generating a reparative milieu reactive to abnormal neuroinflammation, but NAE does not. Therefore, eCBs may be a promising therapeutic target for ASD.