Updated

Barry Zito enjoyed the challenge of facing Josh Hamilton with runners on.

Zito pitched five effective innings and Buster Posey hit a go-ahead single in the ninth to lift the San Francisco Giants over the Los Angeles Angels 5-4 on Sunday.

In a moment that had a regular-season feel to it, Hamilton stepped in against Zito with two on and two outs in the fifth. With fans of both teams cheering, the left-hander threw a slider and two curveballs to get a swinging strikeout.

Hamilton had doubled off Zito earlier in the game.

"Josh is a great hitter, we all know that," Zito said. "I wanted to get back and get him out. I really wanted him to pick up the ball late and the break late."

Zito went 15-8 with a 4.15 ERA last season, his best with the Giants since signing a $126 million, seven-year contract. He allowed one run and six hits Sunday in his sixth start this spring.

"He did a great job, I thought. He did a great job with men on base and he looked crisp," San Francisco manager Bruce Bochy said.

Jason Vargas was even better for the Angels in his fifth Cactus League start. He was charged with one run and five hits while striking out five and walking two in six-plus innings.

Vargas had a career-high 14 wins last year for Seattle, going 14-11 with a 3.85 ERA in 33 starts.

The Angels' bullpen was nowhere near as good as Vargas. Fellow lefty Scott Downs allowed three hits and three earned runs in one-third of an inning. Potential closer Ernesto Frieri gave up the go-ahead run in the ninth. And for the second time in a week, manager Mike Scioscia pointed out that he's not pleased yet with a particular part of his pitching staff.

"You'd rather see this stuff happen down here than when the season starts," Scioscia said. "This is the time to get outs now and our group had a hard time doing that today."

Earlier in the week, Scioscia expressed some concern that his projected five-man rotation had a combined ERA above 7.00 this spring.

He was happy with Vargas, though, saying he had "a great outing."

Vargas was coming off his roughest performance, when he gave up eight hits, five runs and a pair of homers in 5 1-3 innings Tuesday against Milwaukee. He said he didn't change anything about his approach on Sunday.

"I relied off my fastball and changeup," said Vargas, acquired in a trade with the Mariners for Kendrys Morales. "I escaped a few plays. (Third baseman Alberto) Callaspo made a few plays out there.

I have the same mindset I always have. You never went to go out there and get hit."

Los Angeles scored off Zito in the fourth. Albert Pujols opened with a double off the wall in left-center and scored from third two outs later on Howie Kendrick's single.

The Angels' big bats broke out in the seventh against Scott Proctor. Peter Bourjos opened with a triple and scored on Mike Trout's double. Hamilton doubled in Trout and Luis Rodriguez.

The Giants tied it in the eighth against Downs, with two runs scoring on Brandon Crawford's double and another on Guillermo Quiroz's double.

Posey singled off Frieri in the ninth to drive in Hunter Pence.

NOTES: Vernon Wells cleaned out his locker at Angels camp. The New York Yankees were nearing an agreement with Los Angeles to acquire the 34-year-old outfielder in a trade. "It'd be a huge change," Wells said. "I don't think it's ever easy saying goodbye, but at the same time, if this were to happen, it's a good group of guys over there. I'll just get to know a new family." ... The Angels sent Scott Cousins, Tommy Fields, Fernando Cabrera, Luke Carlin, Kevin Johnson and Matt Young to minor league camp.