The Houston Astros have dropped their last three games by a total of four runs. That doesn't make the mounting losses any easier to take, though.

Their latest close defeat came Tuesday night when pinch-hitter Hector Sanchez delivered a go-ahead single in the ninth inning and the San Francisco Giants rallied for a 3-2 victory.

"Eventually, it is going to turn," Astros interim manager Tony DeFrancesco said. "We have a lot of confidence in the guys in there. The effort is there. I am watching guys go hard every day. It's sort of frustrating to the manager and coaching staff not to get the 'W.'"

The Giants were down 2-1 entering the ninth. Brandon Belt singled off Wesley Wright to start inning before pinch-hitter Joaquin Arias doubled down the left-field line off Wilton Lopez (5-3) to tie it at 2.

Sanchez completed the rally with his one-out liner to center that scored Arias.

"It's definitely tough, but they are a good team," Houston's Brett Wallace said. "We played with them tonight."

Houston took the lead on a wild pitch by Matt Cain in the eighth inning. The game was tied 1-all when Jimmy Paredes, in his first game since being recalled from Triple-A Oklahoma City, drew a walk. Wallace singled before a sacrifice bunt by Jason Castro left runners at second and third.

Then came the wild pitch in the dirt that bounced between the legs of catcher Buster Posey and off the backstop. Posey went to get the ball and Paredes trotted home ahead of the throw and over a diving Cain to put Houston up 2-1.

Santiago Casilla (5-5) retired the last two batters in the eighth for the win and Sergio Romo threw a perfect ninth for his seventh save.

Angel Pagan put San Francisco up 1-0 when he connected on a home run to right field with two outs in the fifth. Houston evened it up when Fernando Martinez opened the bottom half with a homer to right-center.

The loss dropped DeFrancesco to 1-7 and came in front of 13,516 fans — the smallest crowd in the history of Houston's 12-year-old ballpark. DeFrancesco took over on Aug. 19 after Brad Mills became the first manager in the majors to be fired this season.

Houston starter Bud Norris was lifted in the seventh with a blister on his right middle finger. He retired the first two batters in the inning before falling behind 2-0 to Pagan.

Trainers checked out Norris and chatted with him before he was replaced by Fernando Rodriguez.

"It is kind of aggravating him a little bit, so he is having a tough time commanding his slider," DeFrancesco said. "Going into the sixth inning and the seventh, it is more painful. ... He can handle it, but when the pain starts beating on him and throbbing, then it's time to come out of the game."

Norris is mired in a career-worst 10-game losing streak and hasn't won since May 21. He allowed six hits and a run with seven strikeouts.

"I just tried to go out there and help my team stay as close as we can and try to win a game," Norris said. "We were ahead late and unfortunately it fell apart."

Cain, who pitched a perfect game against Houston on June 13, allowed six hits and two runs with three walks in 7 1-3 innings.

"I felt good," he said. "I felt like I was able to throw a lot of pitches for strikes anytime I kind of wanted to."

Cain didn't give up a hit until Wallace doubled with one out in the fourth. Pagan fielded it near the wall in center and threw to cutoff man Brandon Crawford, who caught the throw right before Gregor Blanco came dashing in from left field and crashed into him.

The collision sent both players tumbling to the ground, but neither was injured.

Cain was helped by his defense in the first when Castro hit a pop fly into foul territory. Third baseman Pablo Sandoval attempted to make the catch, but the ball bounced out of his glove and into the air. Crawford then made a diving grab before the ball hit the ground.

NOTES: Houston CF Jordan Schafer, on the disabled list with an injured left shoulder, went 0 for 3 and scored a run for Oklahoma City in the third game of his rehab assignment. ... The teams continue the series Wednesday when San Francisco left-hander Barry Zito opposes Dallas Keuchel.