Pitching in a steady rain, Moyer (11-9) gave up two singles and struck out five in his first relief appearance in five years. He also chipped in with two hits. The 46-year-old left-hander was upset last week when he was demoted to the bullpen to make room for Martinez.
Jayson Werth hit his career-best 25th homer and Carlos Ruiz also connected, helping the NL East-leading Phillies win for the sixth time in seven games.
Diamondbacks starter Jon Garland (6-11) allowed five runs and 11 hits in 5 1-3 innings.
A crowd of 45,186 gave the defending World Series champion Phillies a team-record 51 sellouts in only 59 home games. Many came out to cheer Martinez, who used to hear the typical boos when he pitched for the New York Mets.
Martinez received a nice ovation when he walked in from the bullpen. Some fans even gave him polite applause after he failed to get a bunt down in the second.
Stephen Drew hit his third career leadoff homer to start it off for Arizona. Ryan Roberts followed with a single, but Martinez settled in. After starting a double play on a bouncer to the mound, Martinez showed the stuff that made him one of the best pitchers of his generation.
Martinez blew a pair of fastballs - clocked at 90 and 91 mph - past cleanup hitter Mark Reynolds, who has 38 homers. Then it was vintage Pedro. He backed Reynolds off the plate with consecutive inside fastballs before finishing him off with a down-and-away changeup.
Once play resumed in the bottom of the third, the Phillies quickly took a 3-1 lead. Werth's RBI double tied it at 1, and Pedro Feliz and Ruiz had consecutive RBI singles. Feliz was thrown out by right fielder Alex Romero trying to score on Ruiz's hit.
Werth lined a homer to left in the fifth and Ruiz went deep an inning later.
Moyer hadn't appeared in relief since June 24, 2004, when he entered in the 15th inning of Seattle's 9-7 loss to Texas in 18 innings. He hasn't pitched regularly out of the bullpen since 1996 with Boston.
Moyer leads the staff in wins, but he posted a 5.47 ERA in 22 starts. Despite his age, the Phillies gave Moyer a $13 million, two-year contract last December after he recorded a team-high 16 wins.
Moyer lashed out against management after his demotion and he took some heat on talk radio and in newspapers for his critical comments. But fans cheered loudly when Moyer took the mound and they roared when he advanced to third on a fly out in the fourth.
Martinez signed a one-year contract with the Phillies last month after going 5-6 with a 5.61 ERA for the Mets last year. He made three minor league rehab assignments while recovering from a strained shoulder and earned a victory in his first start against the Chicago Cubs last week.
NOTES: Phillies RHP Brett Myers will make his first rehab start for Single-A Clearwater on Thursday. Myers has been sidelined since having hip surgery in June. ... Moyer's last start was Aug. 9 against Florida. ... Garland pitched out of a bases-loaded, no-out jam in the first.