SAN DIEGO — If Arizona’s going to bounce back from its disastrous start, the Diamondbacks will need a lot more outings like the kind Brandon McCarthy turned in Saturday night.

He threw seven shutout innings before the Diamondbacks weathered a ninth-inning rally to hang on for a 4-3 win over the San Diego Padres.

Arizona handed San Diego its fourth straight loss, as the major leagues’ worst offensive team was two outs away from its second straight shutout to Arizona before scoring three runs in the ninth.

McCarthy (1-5), who tied his career high with his fifth straight loss in his last start, gave up three hits, including two doubles to Seth Smith, and allowed just one runner to reach third base. He struck out six and walked one.

“The story of the night was McCarthy’s performance,” Arizona manager Kirk Gibson said.

“We just settled in where we were and not try too hard. We just tried to execute as many pitches that we could,” McCarthy said. “(It) was about the least strong I felt all season. I felt good, I just didn’t feel as strong as I had. It’s good to know that if it’s not feeling right, it’s still there.”

The Diamondbacks had their scoreless innings string snapped at 24 when J.J. Putz allowed a one-out single to Smith and an RBI double to Yasmani Grandal.

Addison Reed then surrendered Jedd Gyorko’s two-run homer. After getting an out, Reed gave up Cameron Maybin’s double and walked Will Venable. Reed ended the game by getting Xavier Nady on a flyout for his eighth save.