After Phillies pitcher Aaron Harang made him look bad in his first two at-bats Monday, Hector Olivera stepped up in the fourth inning and produced the kind of impact that Braves fans had eagerly awaited and hope to see many more times.

Then he made an even bigger impact in the ninth inning.

Olivera hit a two-run, two-out double in the fourth and a two-run homer in the ninth, and Williams Perez pitched seven strong innings in a 7-2 victory that snapped the Braves’ 12-game losing streak, their longest in a single season since 1977.

“I feel great that I was able to help the team get a win,” Olivera said through his translator. “It builds more confidence, and the more we get going the more I’ll start feeling better. But all in all, I’m just happy we were able to get the win.”

The double and homer were the first extra-base hits for Olivera, who’s 4-for-20 with seven RBIs in his first six games. Until Monday, the 30-year-old Cuban rookie hadn’t demonstrated the line-drive power scouts for the Braves and other teams raved about when he was the subject of a bidding war last winter and got a six-year, $62.5 million deal with the Dodgers.

The Braves gave up three major-league pitchers and top infield prospect Jose Peraza to get him in a trade six weeks ago, and until Monday that deal had left a bad taste in the mouths of many Braves fans as the team fell deeper into its worst slump in decades.

“It’s going to be tough,” said Braves manager Fredi Gonzalez, who was also born in Cuba but came to the United States at an early age. “This guy not only changed teams in the middle of the season, he came from a different country, trying to do the whole language thing and stuff like that. It’s going to take him awhile. We’re going to have to be patient with him.

“But you saw what our scouts see – some power. And he’s only been here a short time, but he’s got some RBIs. Even though he was hitting .140 or whatever before today, he still had driven in some runs. That’s a good sign for me.”

Freddie Freeman hit a two-run opposite-field homer in the first inning and the Braves never trailed in just their second win in 21 games and third win in 29 road games since July 7. They were swept in four consecutive road series before winning Monday’s series opener, which moved them to two games ahead of the last-place Phillies in the National League East.

If the Braves had lost, they would have fallen into a tie with the Phillies and been in last place after the All-Star break for the first time since finishing 65-97 in the NL West in 1990.

Perez (5-6) won for the first time in 2 ½ months, allowing six hits and two runs in seven innings with no walks and seven strikeouts. The rookie had been 0-6 with a 9.50 in seven starts since returning from a five-week stint on the disabled list for a bruised foot.

“For once all my pitches were working and I was locating, so I felt really good out there,” Perez said. “There were no walks, that was positive. I decided to go after the guys. My sinker was working really well and I was locating it, so I was going right after them.”

In his first start back from the DL on July 31, he gave up nine hits, career-high nine runs and four walks in 4 1/3 innings against the Phillies at Citizens Bank Park.

On Monday, Perez looked like the pitcher he was before the foot injury, when he worked out of trouble on a regular basis while going 4-0 with a 2.88 ERA in his first 11 major league games including eight starts.

“The thing that sticks out like a sore thumb is Williams not walking anybody,” Gonzalez said. “That’s been his nemesis. He’s going to get a ground ball, but if you sprinkle a couple of walks with a couple of base hits in there, it becomes crooked-number innings. And today he didn’t walk any.”

Rookies Matt Marksberry and closer Arodys Vizcaino pitched a hitless inning apiece for the Braves. Harang (5-15) gave up eight hits and five runs in five innings and has won just once in 13 decisions over his past 17 starts.

The Phillies had runners in scoring position in each of the first three innings, but Perez allowed just one run in that span – Cesar Hernandez doubled to start the third inning and scored one out later on a sacrifice fly.

In the Braves’ fifth, Olivera’s doubled caromed off the left-center field wall at the 374 sign, and sprinted from the batter’s box, not taking anything for granted. He’d struck out in his first two at-bats against Harang and was 2-for-17 with seven strikeouts in his young career before coming to bat in the fourth inning.

“Let’s be honest, those pitches were horrible pitches to swing at,” Olivera said. “I wasn’t focused. I focused a little better on the next few at-bats after that, and I looked for a pitch that I could drive and I got them, and I put a good swing on them.”

Jace Peterson, who had three hits, singled to start the fourth inning and scored on Andrelton Simmons’ double to give the Braves a 3-1 lead. Two outs later, Nick Markakis, who also had two doubles, walked to bring up Olivera, who had struck out flailing at a slider down and away with the bases loaded to end the second inning.

With two on in the fourth, Olivera laid off first-pitch changeup in the dirt and hit the next pitch, a fastball over the middle.