Updated

Dallas Keuchel pitched well for most of the game Wednesday night. Unfortunately for the Astros, the four runs he gave up in the first inning were too much to overcome in a 6-4 loss to the San Francisco Giants.

Houston interim manager Tony DeFrancesco said Keuchel has been bothered by an ear infection.

"I haven't felt good for about a week now, but it's no excuse," Keuchel said. "I just wasn't locating well in the first inning and made a few bad mistakes."

Hunter Pence hit a three-run homer and Joaquin Arias drove in two with a triple to lead the Giants.

Pence has been an Astros nemesis since they traded him in July 2011, hitting four homers in seven games against his former team with the Phillies and Giants.

The Giants had a 1-0 lead before Pence's 19th homer pushed it to 4-0 and elicited the loudest cheers of the night from the sparse crowd.

The announced attendance was just 13,207, the smallest crowd in the history of Houston's 12-year-old ballpark. The previous low came a night before as the Astros struggle to get fans out to see this team that has the worst record in the majors.

"I feel something good happening, but I don't know when it's going to start," said DeFrancesco, who is 1-8 since taking over for the fired Brad Mills. "Hopefully tomorrow will be the day where they can break through and put some smiles on their faces."

Houston cut the lead to one before Arias' triple in the sixth inning, which came after an error by the Astros, pushed the advantage to 6-3.

Angel Pagan hit a leadoff double, advanced to third on a sacrifice bunt and scored on a single by Pablo Sandoval to give San Francisco a 1-0 lead. Buster Posey walked before Pence's shot to left-center off Keuchel (1-7).

Chris Snyder doubled in the second and scored on a two-out single by Brandon Barnes to cut it to 4-1. Snyder slid in behind Posey to beat the throw home.

Jose Altuve singled and stole second base in the third before scoring after consecutive singles by Tyler Greene and Brett Wallace. A sacrifice fly by Jimmy Paredes sent Greene home and got Houston within 4-3.

A single by Fernando Martinez chased San Francisco starter Barry Zito, who was replaced by George Kontos (1-0). He struck out four in 2 2-3 scoreless innings for the win.

Zito yielded seven hits and three runs in a season-low 2 1-3 innings. Javier Lopez got two outs for his fifth save.

The loss was Houston's fourth straight and its 11th in 12 games. DeFrancesco was disappointed that his team let another close one slip away.

"They're playing hard and giving us a chance," DeFrancesco said. "There's a lot of good things happening, and we're playing some good teams that are trying to get to the playoffs."

Keuchel had retired 14 in a row after Pence's homer before Marco Scutaro started the sixth inning with a double that bounced off the wall in left field.

Sandoval drew a walk after that to end Keuchel's night after he allowed four hits and five runs in five-plus innings.

Keuchel was replaced by Mickey Storey, who got Posey to ground into a double play. Pence reached on an error by third baseman Scott Moore before the triple by Arias.

"You see that play made nine of 10 times, and Wallace made a good play to keep it in the infield," DeFrancesco said about the error. "But the next hit was a big hit and it hurt us."

The fly ball by Arias sailed just out of the reach of a leaping Martinez in left field and rolled into the corner to score Sandoval and Pence and push the lead to 6-3.

San Francisco's Guillermo Mota, activated from the restricted list Tuesday after serving a 100-game suspension for his second positive drug test, made his first appearance since May 5 in the sixth inning. Mota, who tested positive for Clenbuterol, which he says was in children's cough syrup, allowed a hit and a walk in two-thirds of an inning.

He was replaced by Jose Mijares, who promptly gave up an RBI single to Moore to make it 6-4. Mota walked Altuve to load the bases before striking out pinch-hitter Brian Bogusevic to escape the jam.

NOTES: Former Astros star Craig Biggio addressed the team before the game at DeFrancesco's request. DeFrancesco said he wants to teach the young team how the Astros were during their years of success when Biggio played. Biggio wouldn't say what he told the team, but said he's willing to do whatever he can to help the club get back on track. ... Houston LF Ben Francisco was scratched before the game with discomfort in his right wrist. He was replaced in the lineup by Martinez. ... Houston CF Jordan Schafer, on the disabled list with an injured left shoulder, went 2 for 4 as he continued his rehabilitation assignment with Triple-A Oklahoma City.