Ryan Ludwick capped his first two-homer game of the season with the fourth walk-off homer of his career Monday night to give the Padres a 5-3, 13-inning victory over the Atlanta Braves at Petco Park.

Ludwick’s drive into the left field seats off Braves reliever Cristhian Martinez followed a one-out walk drawn by Nick Hundley, whose two-out double in the eighth tied the game at 3-3.

“I think it was a fastball,” said Ludwick. “I could be mistaken. It’s kind of a blur sometimes as a hitter. Sometimes as a hitter, I can’t recall what happened.

“I just know I hit it really hard and it barely got out. It’s crazy. I think that ball is 20 rows deep in most ballparks. This park plays crazy at night.”

The homer snapped a four-game losing streak for the Padres, who had also lost six of their last seven. It also gave them only a second win in their seventh extra-inning game of the young season.

“That was good to see,” Padres manager Bud Black said of Ludwick’s game.

“It was good to see Ryan get a couple homers. We’ve seen signs since Chicago of more consistent contact. I know he is feeling better about his offensive game.”

The Padres' five runs matched their highest total over their last eight games, although they finished with only seven hits as their team batting average on the season slipped farther to .209.

Ludwick drove an 0-and-1 pitch from Martinez for his second, two-homer game as a Padre. His most recent walk-off homer came in 2008 with the St. Louis Cardinals.

Ludwick’s first homer of the game was a third-inning shot off Braves starter Derek Lowe.

The Padres bullpen worked seven scoreless innings in front of Ludwick’s homer and in relief of Dustin Moseley -- who saw his string of innings pitched without the Padres scoring a run on his behalf mercifully end at 27 2/3 innings when the Padres scored to tie the game at 1-1 in the bottom of the second.

Moseley, who entered the game with the second-lowest earned run average (1.40) in the National League gave up three runs on four hits, including a first-inning solo homer by Jason Heyward, over six innings.

Six Padres relievers then worked seven scoreless innings with Cory Luebke getting the win after pitching and defending his way out of jams in the 12th and 13th.

The Braves had runners reach base in only four of the 13 innings with Moseley retiring 12 straight hitters after Heyward’s homer and Moseley and four relievers retiring 15 straight Braves after Atlanta scored twice in the fifth to take a 3-2 lead.

The Padres scored single runs in the second, third and eighth.

Orlando Hudson opened the second by taking Lowe the opposite way for a single to left.

Brad Hawpe, who was in 0-for-18 and 1-for-31 famines, also went the other way, driving a double off the wall in left to put runners on second and third. Hudson scored on Will Venable’s grounder to first, but Moseley struck out and Jason Bartlett flew out to center to strand Hawpe at third -– marking the second time in the game and the 23rd time on the season that the Padres failed to score a runner from third with less than two out.