SAN DIEGO -- Of all the ways to win a game, the San Diego Padres did it with a walk-off balk against the major league-leading San Francisco Giants.

Adam Rosales singled in the tying run before Santiago Casilla balked home the winner, and the Padres rallied to beat the Giants 7-6 on Saturday night.

"I guess we'll take it any way we can," San Diego's Travis Jankowski said.

More from FoxSports

"That's the first balk-off I've been a part of," manager Andy Green said. "We kept fighting all the way to the end. We did have some opportunities in the seventh we didn't capitalize on. ... It was a heck of a way to finish."

The Padres started the decisive rally when Alex Dickerson and Derek Norris singled to open the 10th against Casilla (1-3). Norris stole second before Rosales bounced a single past shortstop Brandon Crawford to tie the game.

With Alexei Ramirez at the plate, Casilla appeared to catch a cleat and stutter-stepped during his delivery. A balk was called, bringing in Norris with the winning run.

"He just stumbled, caught a spike when he put his foot down. Clearly a balk," Green said.

"It looked like he was a little discombobulated there on the balk," Giants manager Bruce Bochy said. "He was going home and his cleat caught or something. It's got to be one continuous motion. He did the right thing by throwing the ball, but he stutter-stepped and that's why it's a balk."

Casilla "just got behind," Bochy said. "He got behind 2-0 on the first hitter and had to go at him there, and he just wasn't sharp with his command."

Rosales said he thought Crawford "was going to make a great play, being the great shortstop that he is."

"I couldn't believe it," Rosales said about the balk. "I've never seen that before. But any way we can do it, though, right? Especially after (Buster) Posey hit that home run."

Kevin Quackenbush (6-3) won despite giving up Posey's go-ahead, opposite-field homer leading off the 10th, the Giants' fourth home run of the night.

Posey hit a 91-mph fastball to right field for his 12th homer this season.

San Diego twice had three-run leads, both of which evaporated after Giants home runs.

Angel Pagan hit a two-run shot off rookie starter Luis Perdomo in the third to pull San Francisco to 3-2.

Pinch-hitter Mac Williamson and Ramiro Pena homered off Carlos Villanueva to tie the game at 5 in the sixth. It was Williamson's fourth and Pena's first.

San Diego had the bases loaded and one out in the seventh but failed to score.

The Padres led 5-2 after three innings against Jeff Samardzija, thanks to home runs by rookie Ryan Schimpf and Matt Kemp, and two errors.

Samardzija walked his first two batters. Jankowski stole third and Posey threw the ball into left field for an error that brought in a run. Yangervis Solarte singled with one out to make it 2-0.

Samardzija allowed five runs, four earned, and five hits in five innings. He struck out four and walked four.

Green pulled Perdomo with two outs in the fifth after he allowed Posey's RBI double to pull the Giants to 5-3. Buddy Baumann came on to make his big league debut and retired Crawford on one pitch.

TRAINER'S ROOM

Giants: Bochy said Johnny Cueto, the All-Star Game starter and loser Tuesday at Petco Park, is still feeling a little under the weather but will be OK to pitch Sunday. Cueto said after the All-Star Game that he didn't feel well.

Padres: Green said INF Cory Spangenberg likely won't return this season after re-tearing his left quadriceps.

UP NEXT

Giants: Cueto (13-1, 2.47 ERA) is scheduled to start Sunday's series finale. He allowed three runs on two homers in 1 2/3 innings to take the loss in the All-Star Game.

Padres: RHP Edwin Jackson, who hasn't started in two years, will be promoted from Triple-A El Paso to start Sunday. His last start was for the Chicago Cubs in 2014. Since then he's made 39 relief appearances for Chicago, Atlanta and Miami.