SAN FRANCISCO — Jeff Samardzija had a simple game plan against the Atlanta Braves that helped him earn a much-needed win and moved the slumping-but-still-surviving San Francisco Giants closer to first place in the NL West.

“Just made them hit it to (shortstop Brandon) Crawford mostly,” Samardzija said, referring to his Gold Glove teammate.

The plan couldn’t have worked out much better for Samardzija or the Giants.

Sparked by a handful of defensive gems by Crawford, Samardzija and two relievers combined on a seven-hitter, and San Francisco beat Atlanta 7-0 on Friday night.

Samardzija (11-9) had an uneven outing and had to pitch out of two early jams to win for only the fourth time since May 30. He got plenty of help from Crawford, who threw out a runner at third in the first inning, snared a liner to end the second with the bases loaded then made a nifty bare-handed grab to throw out Dansby Swanson to end the sixth.

“I like getting groundballs so I’m glad that (Samardzija) feels confident in me to make those plays for him,” Crawford said.

Samardzija allowed seven hits, walked three and struck out six. He also doubled and scored in the fourth.

Atlanta failed to score in the first after putting runners at second and third with one out. The Braves also came up empty after the first three batters reached base in the second, then ran themselves out of another opportunity in the fourth when Jace Peterson was called out after getting hit by the ball on pitcher Joel De La Cruz’s single.

“Rocky start but he did a great job of getting out of those jams,” Giants manager Bruce Bochy said of Samardzija. “He just kept his concentration and his poise. Saved the game probably at that point for us.”

Angel Pagan homered while Brandon Belt, Denard Span and Buster Posey added two hits apiece for the Giants. San Francisco scored six runs on two-out hits and benefited from three Atlanta errors.

Freddie Freeman had two hits for Atlanta, one day after taking a hard fall while flipping over a railing chasing a foul ball.

Hunter Strickland and Cory Gearrin retired three batters apiece for San Francisco.

The Giants benefited from the Braves’ shaky defense to give Samardzija an early cushion.

San Francisco had four consecutive two-out hits off De La Cruz (0-7) in the first inning following a throwing error by Atlanta shortstop Swanson.

“We go up early and it’s a whole different game, really,” Braves interim manager Brian Snitker said. “We just couldn’t score and it looked like (Samardzija) got locked in pretty good.”

San Francisco went up 5-0 in the second on Pagan’s ninth home run, three batters after Gorkys Hernandez reached on second baseman Peterson’s fielding error.

Belt, who had an RBI single and scored in the first inning, doubled in Posey in the fifth.

The Braves couldn’t keep up.

NO HELP FOR THE PITCHER

De La Cruz remained winless after allowing seven runs in four innings but he can’t shoulder all the blame for his record. The Braves have failed to score in five of the eight games started by the right-hander and he is receiving just 1.3 runs of support per start. “I thought he threw the ball OK but (your teammates) make some miscues and you need to get the next guy out and he wasn’t able to do that,” Snitker said. “It wasn’t real good, really.”

TRAINER’S ROOM

Braves: Freeman showed no lingering effects after hurting his back during Thursday’s game in Arizona. Freeman doubled in the first inning and reached on an infield single in the fifth.

Giants: Outfielder Hunter Pence was held out after straining his right hamstring a day earlier. Pence is hopeful of returning to the lineup Saturday.

UP NEXT

Braves: RHP Mike Foltynewicz (6-5) faces the Giants for the second time this season Saturday night. Foltynewicz, who beat San Francisco on May 30, is winless in his last two starts overall.

Giants: RHP Jake Peavy (5-9) returns to the rotation for the first time since being demoted to the bullpen following the trade for Matt Moore on Aug. 1. Peavy last started on May 30 against Washington.