ANAHEIM, Calif. – His pitch count had risen over 100 on a hot, 90-degree day. Zack Wheeler’s tank was almost empty. He had just walked two batters in a tie game. There were two outs in the bottom of the sixth inning and there was nowhere to turn.

Despite a recent slump that saw him walk 15 batters and rack up a 8.38 ERA in his previous four starts, Wheeler remains one of baseball’s very best pitchers.

So, after falling behind Jose Siri with two quick balls and the game on the line, Wheeler was able to climb back into the count and register a swinging strikeout on a 3-2 curveball.

“I got behind there,” the pitcher said later. “I had just walked two guys and I’m thinking I can’t walk this guy, just bear down. I’ve got J.T. (Realmuto) back there and he’s got confidence in me. The curveball was working today so we leaned on it and I was able to throw it for a strike.”

Wheeler has 154 strikeouts on the season. This one might have been his most important.

Because moments after keeping the Los Angeles Angels at bay in the bottom of the sixth, Wheeler watched teammate Edmundo Sosa clout a tie-breaking homer to left to help send the Phillies on to a 5-2 victory and a sweep of the three-game series Sunday afternoon at Anaheim Stadium.

Wheeler earned his first win since July 12.

The Phillies have won 13 of their last 15 to improve to a season-high 17 games over .500. They are 20-7 in August with one more game to play in the month.

Sosa, getting the start at third base against lefty Yusei Kikuchi, had a huge series. Before Sunday’s homer, he belted a ninth-inning grand slam to key Friday night’s comeback win. He has seven homers on the season.

The big story Sunday was the work of Wheeler. His recent struggles had resulted in alarm bells sounding. In the wake of Monday’s four-homer, five-walk performance in a loss at Seattle, the Phillies’ pitching brain trust spent the week diving into the 36-year-old right-hander’s struggles. A mechanical adjustment was made. Wheeler struggled with his control, walking a batter and hitting another, as he loaded the bases and gave up a run in the first inning. But a double-play ball mitigated the early problems. After that, Wheeler looked pretty close to his old self. In all, he went six innings and allowed four hits and a run while walking three and striking out six. Not bad.

“He wasn’t sharp against the first few batters, but once he got that double play, I felt confident he’d be himself today,” Realmuto said. “His four-seam fastball had more life today, more carry, and he was locating it better. When he’s doing that, he’s at his best and he can blow away good fastball hitters with his fastball. He’s close. We have all the faith in the world that he’s going to be the guy for us that he’s been in the past.”

Wheeler confirmed that he’s close to being himself, but added, “I’m still not out of it. It’s been tough. I’ve just had to grind. I expect a standard from myself and I just haven’t been there.”

With the help of the team’s pitching instructors and analysts, Wheeler spent the days leading up to the start digging into his mechanics.

“The biggest thing they talked about was posture,” manager Don Mattingly said. “He was getting a little bit of lean (toward home plate) and that caused some problems.”

“We feel like we kind of figured some things out,” Wheeler said. “When I feel off, I look at the biomechanical stuff because you see more stuff than regular video. You can see the smallest little difference. My glove was down two more inches than where it had been all year in my last start. They showed me a graph of how it’s been trending, so we brought the front arm up a little bit and went from there. Everything synched up off that. I was able to get my weight on my back leg and that helped me be more direct rather than rotational.”

Half of Wheeler’s 108 pitches were four-seam fastballs. The pitch averaged 95.4 mph and topped out at 96.3.

Wheeler allowed a leadoff double in the third but pitched over it with the help of center fielder Derek Hill, who made a nice running/diving catch for the second out.

The next time Wheeler got in trouble was in the bottom of the sixth. He handled that problem all by himself with a full-count curveball to Siri and his 15th swing and miss of the day.

Mattingly thought about removing Wheeler before the Siri at-bat.

“He was getting toward the end, but I felt like he deserved that shot right there,” Mattingly said. “We know what he can be and what he can do. This was a good start to head in that direction. It’s good to get him going in that direction.”

Wheeler’s battery mate, Realmuto, first tied the game with a solo homer in the third. Sosa put the Phils up in the seventh and they tagged on with two runs in the eighth and another in the ninth.

Rookie right-hander Alex McFarlane continued to impress with a scoreless seventh. Jose Alvarado pitched into some trouble in the eighth, but got out of it with the help of Orion Kerkering, who stayed on for the ninth. Kerkering allowed a run before getting the final out.

Bryce Harper singled and doubled to extend his career-best on-base streak to 32 games.

The Phillies’ next two series are important ones. They open a three-game series in Arizona against the Diamondbacks on Monday night. Arizona currently holds the third NL wild-card position, 4 1/2 games behind the Phillies. With a good series, the Phils could put more space between themselves and the D-Backs.

On Friday, the Phils open a four-game series with the Atlanta Braves at Citizens Bank Park. It will be the first of seven meetings the teams will have in the next two weeks. The Braves hold the lead in the NL East by five games over the Phils.

Wheeler lines up to pitch the second game of the series. He might not be all the way back, but he took a major step forward Sunday.