SAN FRANCISCO — Ten months ago, Tim Hudson knew he would spend this week of July with his wife, three children and dog.

But he didn’t think they would be in Minneapolis for the All-Star game, and as Hudson looked down at a surgically repaired right ankle late last summer, he wasn’t sure they would be anywhere close to a baseball diamond, period.

“There was a lot of uncertainty there,” Hudson said Sunday. “It wasn’t until probably two months after surgery that I thought my career was going to continue.”

Hudson isn’t just back on a mound. He has been an ace for the Giants, a second All-Star holding the reins for a surging quintet. At the break, the 39-year-old is 7-6 with a 2.87 ERA.

“This is a first half of a season that I don’t think me or anybody else really anticipated,” Hudson said. “It’s very satisfying. I just feel blessed to be playing, much less have an All-Star caliber first half.”

Hudson had won three consecutive starts for the Atlanta Braves last season and was leading the New York Mets 6-0 in the eighth inning on July 24 when Eric Young Jr. hit a chopper to the right side. As he had done hundreds of times before, Hudson raced to the bag, reached for the ball and touched first. He immediately fell to the ground, his right foot hanging in the air. Young had accidentally stepped on Hudson’s ankle, fracturing it and causing ligament damage.

In a strange way, this made him a perfect fit for the Giants, who dealt with Buster Posey’s catastrophic ankle injury two years earlier. Members of the front office had been eyeing Hudson before the injury, and they kept tabs on his progress as the offseason approached. The thinking was that Hudson would be able to recover his form because he relied on smooth mechanics and had not suffered an arm injury.

With Tim Lincecum already back in the fold and confidence that Ryan Vogelsong would agree to a one-year deal, just one rotation piece was missing: Another veteran, ideally on a two-year deal. Bronson Arroyo (now an Arizona Diamondback) was an option, but he insisted on a three-year deal, a nonstarter for an organization that had given Marco Scutaro three years and was looking at two seasons of uncertainty at second base. Dan Haren was intriguing but was intent on pitching near his Orange County home and signed a one-year deal with the Los Angeles Dodgers.

The Giants signed Hudson to a two-year, $23 million deal Nov. 19, less than two weeks after he had a surgical screw removed from his ankle. He had not been cleared to run, but while taking an exhaustive physical, he was able to do enough to ease any lingering fears. Hudson and head trainer Dave Groeschner traversed the city from dawn till dusk, going from exam to exam and stopping only for lunch. Groeschner watched Hudson’s gait throughout, and he liked what he saw.

Little has changed in the months since. Hudson was sore several times early, but the Giants knew what to expect after their experience with Posey. The fourth-oldest starter in the majors, Hudson threw 119 innings in the first half.

“I feel good physically. Obviously I’ve logged some innings, but I feel as good now as I (did) early in my career,” he said. “Hopefully there are 15 or 20 more starts left in me.”

The first 18 have been mostly excellent. Hudson ranks eighth in the league in WHIP (1.10), and 10th in ERA and strikeout-to-walk ratio (4.11).