ST. LOUIS -- Aledmys Diaz learned a valuable lesson at the All-Star Game.
The St. Louis rookie infielder's walk-off single in the ninth inning gave the Cardinals a 6-5 come-from-behind victory over the San Diego Padres on Thursday night.
St. Louis, which scored four runs in the eighth, recorded its first four-game series sweep at home since beating Colorado on Sept. 30-Oct. 3, 2010.
More from FoxSports
San Diego has lost four of seven.
Diaz ripped a full-count, one-out, bases loaded pitch into left field off reliever Carlos Villanueva (1-1).
In this month's All-Star Game, Diaz took a called third strike with the bases loaded to end the eighth inning of the AL's 4-2 victory.
He decided that wasn't going to happen in a similar situation on Thursday.
"This time, I wanted to be aggressive," Diaz said. "Go get it, if it looks good."
Tommy Pham led off the bottom of the ninth with a double. Greg Garcia drew a walk and Jeremy Hazelbaker moved the runners over with a perfect bunt. Jedd Gyorko was walked intentionally to set the stage for Diaz's heroics.
St. Louis reliever Jonathan Broxton (2-2) picked up the win with a scoreless ninth.
Now Walk It Off, Now Walk It Off! 🚶🚶🚶 pic.twitter.com/y2PA0cTWfO— St. Louis Cardinals (@Cardinals) July 22, 2016
The Cardinals erased a 5-1 deficit in the eighth. Hazelbaker led off with a double and he scored on hit by Gyorko, his seventh RBI of the series against his former team. Kolten Wong doubled with one out and Stephen Piscotty hit a three-run homer to center field.
"This was definitely a special one," Piscotty said. "It's a lot more fun when those things happen and you end up winning. This was a great way for our team to come back."
Yangervis Solarte homered in the eighth inning to extend the Padres' franchise-record home run streak to 19 consecutive games. The streak is the longest in the National League since the Milwaukee Brewers hit home runs in 20 consecutive games in July 2008.
His 10th home run of the season pushed the lead to 5-1.
"To put it simply, it's just hard work," Solarte said of the home run streak. "I know we have some power on this team."
Andrew Cashner, the subject of trade rumors the past few days, allowed one run and three hits for San Diego. He struck out eight and did not walk a batter. Cashner has allowed one run or less in three of his last four starts.
"I've been working on a slider for the past couple weeks and I've finally got a good feel," Cashner said.
Alexei Ramirez had three hits and drove in two runs for the Padres, who have scored an NL-best 226 runs since June 1.
St. Louis starter Adam Wainwright gave up two runs and seven hits over six innings. He struck out eight and did not walk a batter.
Wainwright believes the comeback win can lead to better things.
"We're ready for a good streak here," he said. "We're ready to run off a 12-spot or something."
Ramirez gave his team a 1-0 lead with a run-scoring single in the fifth that brought in Ryan Schimpf, who doubled to start the inning. Travis Jankowski followed with an RBI double.
St. Louis outfielder Matt Holliday left the game in the sixth inning after he was hit in the face by a pitch. The ball appeared to strike Holliday's helmet and then glance off his nose. X-rays were negative and he is listed as day-to-day.
The Cardinals tied their largest comeback of the season by rallying from four runs down.
"We made some things happen," St. Louis manager Mike Matheny said. "We got down and the guys kept playing the game. Watching them make plays, big hits, it was a great day for us."
Padres: INF Brett Wallace was reinstated from paternity leave on Thursday. Wallace and his wife, Taylar, welcomed their first child, a boy named Beckett, on Monday. ... LHP Keith Hessler and INF/OF Alexi Amarista were optioned to Triple-A El Paso.
Cardinals: INF/OF Brandon Moss took grounders before Thursday's game. Moss was placed on the 15-day DL on July 5 with a sprained ankle. He is expected back sometime within the next two weeks.
Padres: RHP Luis Perdomo (3-4, 7.36) will face RHP Tanner Roark (9-5, 2.82) in the first of a three-game series in Washington on Friday.
Cardinals: RHP Michael Wacha (5-7, 4.45) takes on RHP Brandon McCarthy (2-0, 1.69) in the first of a three-game set against the Dodgers in St. Louis on Friday. Wacha is 2-4 with a 4.85 ERA in 10 home starts this season.