SAN FRANCISCO -- Enough went right Tuesday night for the Giants to propel them past the Washington Nationals, 4-2, ending a five-game losing streak.

And enough went wrong for the Giants to make them believe that a carefree existence will elude them this season.

Todd Wellemeyer, whose 3-1 record at AT&T Park suggests that he enjoys the place as much as the seagulls, pitched six effective innings and launched a two-out, fifth-inning rally that ended the Giants' skid of 24 consecutive scoreless innings.

But Edgar Renteria, who played slick defense at shortstop, went 2-for-3 and drove in Wellemeyer to open the scoring in the Giants' four-run outburst, pulled his right hamstring while running to first base on a seventh-inning sacrifice bunt and could be sidelined for an indefinite period.

Manager Bruce Bochy's intent to keep Renteria, Juan Uribe and Freddy Sanchez in the lineup prompted him to move first baseman Aubrey Huff to left field, where he hadn't played since 2004. Not only did Renteria respond by having one of his best games of the season, but Sanchez also contributed a two-run double.

Now Bochy must make another lineup change -- an unwanted one -- to account for Renteria's absence.

"You're trying to get some consistency. That's what's frustrating," Bochy said. "Edgar had such a great game and he could be down for a little while."

Renteria, who was activated from the 15-day disabled list just last Saturday after recovering from a right groin strain, was visibly upset. "I don't know what I can say," he repeated.

In a lighter vein, the origin of the Giants' fifth-inning rally was equally inexplicable. Wellemeyer was 1-for-14 this season when he reached for Livan Hernandez's 0-2 fastball and poked it into shallow right field for a single, prolonging the fifth inning.

"Somehow I was looking outside and he threw it out there," said Wellemeyer, a .141 career hitter.

That was the first of five consecutive two-out hits off Hernandez (4-3) that shattered a scoreless tie. Andres Torres singled before Renteria drove in Wellemeyer with another single. Sanchez sliced his hit to right field and scored on Pablo Sandoval's double off the left-field wall.

"You get something started in the most unlikely places. That's how you get out of a rut," Huff remarked after the Giants' 12th victory in 14 games against Washington since 2008.

"Unbelievable," said Hernandez, the former Giant whose 1.62 ERA entering the game was the third-best in the Major Leagues. "I threw good pitches and they hit it. Today, I feel very good and I lose the game with two outs. I can't say anything."

Wellemeyer (3-4) maintained his shutout until the seventh, when consecutive singles by Ryan Zimmerman, Adam Dunn and Josh Willingham chased him. San Francisco's bullpen muted the Nationals afterward, with Brian Wilson striking out the side in the ninth inning for his 11th save.

Wellemeyer couldn't explain the disparity between his performance at home, where he owns a 3.03 ERA, and on the road, where he's 0-3 with a 9.35 ERA.

"If you can figure it out, let me know," Wellemeyer said.

Wellemeyer has become a stopper, as long as he's pitching in San Francisco. Before his most recent AT&T Park outing, on May 14 against Houston, the Giants had completed a 1-5 trip through New York and San Diego and were struggling just as much offensively as they recently have been. He then pitched into the eighth inning in an 8-2 triumph. That night, Wellemeyer arrived at the park convinced that the Giants would score big. He had that same sense this time, following the team's 1-6 sojourn through San Diego, Arizona and Oakland.

"I had the vibe going and I think they fed off it again," Wellemeyer said.

The Giants will try to sustain that vibe during their nine-game stretch at home, where they're 14-8.

"It's all about getting past [a slump]," Wellemeyer said. "Every great team goes through it and once you get past it, it feels great."

Now the Giants must get past Renteria's misfortune.