Because ketamine and magnesium block NMDA receptor activation by distinct mechanisms of action, we hypothesized that in a model of inflammatory pain in rats the combination of ketamine and magnesium might be more effective than ketamine alone. Antinociceptive activity was assessed by the formalin test in male Wistar rats (200–250 g). Animals were injected with 100 μL of 2.5% formalin to the plantar surface of the right hind paw. Data were recorded as the total time spent in pain‑related behavior after the injection of formalin or vehicle (0.9% NaCl). Ketamine and magnesium sulfate given separately reduced nocifensive behavior in the second phase of the formalin test in rats. When ketamine was applied after magnesium sulfate, the log dose‑response curves for the effects of ketamine and the magnesium sulfate‑ketamine combination revealed antagonistic interaction, and about 1.6 (CL 1.2–2.4) fold increment in ketamine dosage. A low dose of magnesium sulfate (5 mg/kg, subcutaneously) administered after ketamine increased the antinociceptive effect of ketamine by a factor of only 1.2 (CL 0.95–1.38), indicating an additive interaction. There was a 1.8‑fold reduction in dosage of ketamine when ketamine was administered before rather than after the magnesium sulfate. The present study revealed that both ketamine and magnesium reduced pain‑related behavior in the second phase of the formalin test in rats. Ketamine, when administered before or after the magnesium, provided additive or antagonistic antinociceptive interactions, respectively. Whether there will be an additive or antagonistic antinociceptive interaction between ketamine and magnesium depends on the order of drug administration.