CHICAGO -- Cole Hamels is searching for his usual form. It's a work in progress.
He found a way Tuesday night.
"It's just kind of the baby steps and getting back to knowing what I'm capable of doing," Hamels said.
The Cubs (67-58) earned their third straight win and stayed a half-game back of NL Central-leading St. Louis, which posted a 9-4 win over Milwaukee.
Hamels (7-4) permitted three runs and five hits in his first win since June 12 at Colorado. The left-hander went 0-2 with a 6.12 ERA in his previous six starts, including a shaky performance at Philadelphia last week.
"It's kind of like when you have that golf swing and you're thinking about 10 different things and you can't hit the ball off the tee box," Hamels said. "Luckily, I can get the ball off the tee box right now."
The game was tied at 3 when the Cubs went ahead to stay in the fifth, helped by a successful challenge.
Rizzo and Baez bumped into each other just beyond the base as shortstop Abiatal Avelino made the relay to first. It was originally called a double play, but Baez was ruled safe after the review.
"Couldn't get that double play," Giants manager Bruce Bochy said. "That hurt."
"I think I put all I had into it and just came up a little short," Belt said.
Kyle Ryan and Rowan Wick each got three outs before Craig Kimbrel finished for his 10th save in 12 chances. It was Kimbrel's first save opportunity since he returned Sunday after being sidelined by right knee inflammation.
Rizzo went 3 for 3 and scored three times in his first multihomer game this season. Castellanos hit his seventh homer in 18 games since he was acquired in a July 31 trade with Detroit.
Castellanos "has great at-bats every at-bat," Rizzo said, "and that's big. You add another professional at-bat every time and he's doing damage."
Rizzo gave Chicago a 3-2 lead when he led off the third with his 23rd homer, a drive to right off Tyler Beede. But Pillar responded with his team-high 18th homer in the fourth.
The Cubs announced veteran infielder Ben Zobrist will play for Double-A Tennessee on Thursday and Triple-A Iowa on Friday and Saturday.
Zobrist is working his way back to the majors after going on the restricted list May 8. Zobrist, who has been dealing with a divorce, is batting .222 (6 for 27) in nine minor league games this month.
Giants: INF Pablo Sandoval is going to see Dr. Neal ElAttrache in Los Angeles for a second opinion on his ailing right elbow. Sandoval has been dealing with bone chips for years, but Bochy said they want to make sure nothing else is going on. ... RHP Johnny Cueto (Tommy John surgery) was slated to make his second rehab start with Class A San Jose on Tuesday night and fourth overall. If all goes well, he is expected to make his next rehab appearance with Triple-A Sacramento. ... OF Steven Duggar (left shoulder sprain) is likely out for the season, but doesn't need surgery. "We got the best news we probably could have gotten with him," Bochy said. ... RHP Shaun Anderson (middle finger blister) was scheduled to make a rehab start for Sacramento on Tuesday night.
Cubs: RHP Steve Cishek (left hip inflammation) was activated from the 10-day injured list. INF David Bote was optioned to Triple-A Iowa on Monday to make room for Cishek, who is 3-5 with seven saves and a 3.58 ERA in 54 games this season.
Right-handers Dereck Rodriguez and Yu Darvish pitch Wednesday night. Rodriguez (5-6, 4.79 ERA) tossed seven sparkling innings in San Francisco's 7-0 victory at Arizona on Thursday. Darvish (4-6, 4.21 ERA) is 2-2 with a 2.77 ERA in his last eight starts for Chicago.
Jay Cohen can be reached at https://twitter.com/jcohenap
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Iglesias' double in 10th leads Reds past Cubs 3-2
Jose Iglesias had an RBI double in the 10th inning and five Cincinnati pitchers combined for a four-hitter as the Reds recorded their second straight win over the playoff-contending Chicago Cubs 3-2 on Wednesday night.
Suarez's HR makes MLB history
Eugenio Suarez's 48th home run of the season gives him the most in a single season by a Venezuelan-born player.
Contreras hits a no-doubter
Willson Contreras jumps on an 0-2 pitch and leaves no doubt as is lands over the wall in left field to tie the game.
Grichuk slam negates Buchholz dud as Jays beat Orioles 11-10
Randal Grichuk hit a grand slam with two outs in the ninth inning, and the Toronto Blue Jays rebounded from an ineffective start by Clay Buchholz to rally past the Baltimore Orioles 11-10 on Wednesday night.
Twins lose 3-1 to White Sox, division lead trimmed to 4
Held without a hit until the sixth inning, the Minnesota Twins managed only three in 3-1 loss to the Chicago White Sox that shrunk their AL Central lead Wednesday night.
Santander unloads 418-foot homer to center
Anthony Santander extends the Orioles' lead with a two-run jack.