Thank goodness that painful streak is over.

The Phillies beat the San Diego Padres 4-3 Friday night to snap a four-game losing streak.

The Phillies are 62-60. They are four games behind the first-place Altanta Braves in the NL East.

The Braves, winners of three straight NL East titles, are 14-3 in August. They continued their roll with their seventh-straight win Friday night in Baltimore.

The Orioles are the worst team in baseball and a complete embarrassment. They are in full tank mode, trying to lose games and succeeding at it. They have lost 16 in a row. The Braves play them again on Saturday and Sunday.

The Padres have lost eight-of-nine and are slipping away in the race for the second NL wild-card spot. The Padres’ loss, along with the Cincinnati Reds’ 5-3 win over the Miami Marlins on Friday, moved the Padres and Reds into a tie in the wild-card race. The Phillies are four games back in the NL wild-card standings.

“We really needed this win,” Phillies manager Joe Girardi said. “The bullpen did a terrific job. (Starter) Matt Moore did a terrific job.”

The Phils Moore to the mound against Blake Snell, which wasn’t promising, but Moore dealt evenly with Snell, allowing two runs in four and a third against Snell’s three in five.

The Phils were able to stall the Padres, with Hector Neris, Archie Bradley, and Ian Kennedy throwing a combined four and two-thirds allowing only one run, while scattering, somehow, six walks, and a hit.

The Phillies scored three runs in the third inning against Padres starter Blake Snell. With two out, Jean Segura walked and stole second base. J.T. Realmuto doubled home Segura, and Harper followed with a long, 430 foot home run to right field.

Trailing 3-0, the Padres scored two in the bottom of third against Moore. One batter after Tommy Pham walked, Manny Machado hit a low line-drive homer that hit the top of the left-field fence and bounced into the stands. That home run was the hardest hit ball in the MLB this season, as it was hit 119.6 mph.

In the sixth inning against Phillies reliever Hector Neris, San Diego loaded the bases with two outs. However, Tommy Pham grounded out weakly to shortstop Ronald Torreyes, ending the threat.

The Phils added an insurance run in the eighth for a 4-2 lead. Andrew McCutchen hit a double to left field off Emilio Pagan, driving in Segura from first base.

“McCutchen’s RBI is the difference in the game,” Girardi said. “He was swinging the bat well all night.”

Hosmer, who reached base four times via a single and three walks, led off the eighth with a walk against Phillies reliever Archie Bradley and moved to third on a single to center by Will Myers. Bradley then struck out Adam Frazier and pinch-hitter Trent Grisham before walking Pham to load the bases.

Bradley was lifted in favor of closer Ian Kennedy, who had to face Fernando Tatis Jr. with the bases loaded.

“You probably couldn’t draw up a tougher situation to come in there,” Moore said of Kennedy having to face Tatis.

Kennedy hit Tatis in the helmet with a fastball, forcing in a run. Tatis dusted himself off and was not injured on the play.

“It just got away from me,” Kennedy said of hitting Tatis.

The next batter, Machado, eventually struck out to end the inning. But during the at-bat, Padres manager Jayce Tingler was ejected for arguing called striked number two.

After the strikeout, Machado was ejected during a heated argument with the home plate umpire. Machado chucked his batting gloves at home plate as he walked back to the dugout.

“I just tried to get ahead of Machado,” Kennedy said. “It’s nice to get a call to go my way. … The umpire didn’t change the zone all game. As a pitcher, you just have to pitch to it.”

Aaron Nola will start for the Phillies Saturday night, while Joe Musgrove starts for the Padres.