Marte belted a two-run homer and added an RBI single for the Diamondbacks (73-68), who recorded their third win in four games.
Arizona moved a half-game ahead of the Miami Marlins (72-68) and the idle Cincinnati Reds (73-69) for the third National League wild-card slot. The Marlins dropped a 10-0 decision to the Los Angeles Dodgers earlier on Thursday.
Diamondbacks starter Ryne Nelson (7-7) allowed one run on two hits and two walks while striking out three batters in 5 2/3 innings. Four relievers combined for three scoreless innings before Paul Sewald recorded the final out to secure his 31st save.
Arizona shortstop Jordan Lawlar, the sixth overall pick in the 2021 draft, went 1-for-4 in his major league debut. Like Nelson, Lawlar also was promoted from Triple-A Reno prior to the game.
Seiya Suzuki tripled and scored on a sacrifice fly by Jeimer Candelario in the fifth inning for the Cubs (76-65), who saw their four-game winning streak end and fell two games behind the first-place Milwaukee Brewers (77-62) in the NL Central.
Pham opened the scoring in the first inning after depositing a first-pitch fastball from rookie Javier Assad (3-3) over the wall in right-center field for a solo shot.
Arizona added to its advantage in the third inning. Geraldo Perdomo singled to lead off the inning before Marte stepped up two batters later and sent a 3-2 cutter from Assad over the wall in center field for his 22nd of the season.
Assad took the loss after permitting three runs on seven hits in 5 1/3 innings. He walked one without recording a strikeout.
Suzuki's triple off the right field wall with one out in the fifth inning was Chicago's first hit of the game. Suzuki didn't stay on third base for long, as he scampered home on Candelario's sacrifice fly to right field.
The Diamondbacks extended their lead to 5-1 in the eighth inning. Marte drew a leadoff walk against Keegan Thompson, Pham sent a first-pitch fastball over the wall in right-center field for his 15th homer of the season.
Marte added an RBI single in the ninth inning for Arizona. Dansby Swanson responded with a run-scoring single in the bottom of the ninth off Joe Mantiply. Sewald entered with two on and two outs, and he got Suzuki to hit a game-ending groundout.
—Field Level Media