The Cardinals broke a three-game losing streak with their first win since July 5.
Eduardo Escobar hit his 19th homer for Arizona, which snapped a four-game win streak.
ONeill, recalled from Triple-A Memphis on June 29, also drove in four runs in a 6-0 win over Kansas City on May 21, 2018.
His two-run double in the first inning gave the Cardinals a 2-0 lead. He added a homer off Merrill Kelly (7-9) in the third to push the advantage to 4-1.
Hudson (8-4) gave up three hits and two runs in a 94-pitch stint. He struck out five and walked four.
Carlos Martinez got the last four outs for his fourth save in six chances.
Kelly surrendered just one earned run over five innings. A two-out error by third baseman Jake Lamb in the first allowed the inning to continue.
Nick Ahmed had a run-scoring hit in the second for the Diamondbacks. He has reached safely in a career-best 14 successive games.
St. Louis first baseman Paul Goldschmidt, who played eight seasons in Arizona (2011-2018), reached on the error by Lamb but went 0 for 3 at the plate and is hitless in seven at bats in the series.