Prenatal exposure to valproic acid (VPA) has been shown to increase the risk of autism in children. This study examined the effect of metformin on VPA‐induced autism spectrum disorders in rats. Pregnant albino rats administered VPA (500 mg/kg, i.p.) or normal saline (10 mL/kg, i.p.; vehicle‐control) on gestational day 12.5. The pups were given metformin (5, 50 or 500 mg/kg, p.o.) or vehicle (10 mL/kg, p.o.) daily from postnatal day (PND) 21–50. Social behaviour, spatial learning/reference memory, repetitive behaviour and anxiety were assessed using the three‐chamber social assay, Morris water maze (MWM), Y maze and elevated plus maze tests (EPM), respectively. On PND 51, the animals were euthanized and brains removed for biochemical assay. In utero VPA exposure caused significant reduction in sociability index, social novelty preference index in three‐chambered apparatus and spatial learning and reference memory deficits in the MWM task as well as increase in repetitive/anxiety‐like behaviour in Y maze and EPM tests, respectively, which were ameliorated by post‐treatment with metformin in a dose‐dependent manner. Moreover, prenatal VPA increased malondialdehyde (MDA) and nitrite levels as well as deficits in antioxidant enzymes activities in the hippocampus and prefrontal cortex (PFC) which were attenuated by metformin administration. Similarly, VPA‐induced increase in acetylcholinesterase activity in the hippocampus and PFC were attenuated by postnatal treatment with metformin. Findings from this study showed that postnatal administration of metformin prevented valproic acid‐induced autistic‐like behaviour. Hence, metformin could be a potential adjunct in the management of autism spectrum disorders.