Posey sent an 0-1 pitch from Juan Nicasio (5-6) just inside the left-field foul pole for his 18th homer of the year and second career walkoff homer. He also had one on May 3, 2013, against the Dodgers.
Bochy and Hudson each headed home with souvenir balls. Hudson thought the manager was taking him out of the game when he came to shake the pitcher's hand for his 2,000th strikeout after the sixth.
''I didn't even know I had 2,000 strikeouts,'' Hudson said. ''I'm not really considered a strikeout guy. I'm just glad I can go out there and still give my team a good chance to win. Bochy, I think that's a little more impressive than 2,000 strikeouts.''
Santiago Casilla (2-3), who was ill Tuesday, plunked leadoff hitter Drew Stubbs in the back to start the ninth. Justin Morneau then doubled him home to tie the game at 2. Casilla got a key double play to get out of the inning.
''He didn't let the game get away,'' Bochy said. ''I compliment Casilla for not losing his poise.''
Hudson's impressive eight-inning, eight-strikeout outing was wasted, and removing him after eight was a tough call for Bochy. The right-hander reached 2,000 Ks when he fanned Franklin Morales in the sixth.
Posey followed his two-home run performance a night earlier with a go-ahead single in the seventh inning, then an even bigger hit. He has hit safely in 12 of his past 13 games.
''Buster does what you expect Buster to do, go up there and have a good at-bat,'' Hudson said. ''The really good hitters in the game, when they get good pitches to hit they're going to make them pay, and that's what he did.''
After Madison Bumgarner's one-hit gem in a 3-0 win Tuesday, Hudson had his own fine outing. He didn't allow a hit until Corey Dickerson led off the fifth with a splash home run into McCovey Cove.
It marked the 100th homer into the bay in the 15th-year ballpark's history and 34th by a visiting team. Carlos Gonzalez hit the Rockies' other two.
Morales saw his winless stretch reach eight outings since a July 8 victory against San Diego.
All of Morales' wins this season have come against the NL West, and he certainly pitched well enough to keep his team in the game. The left-hander allowed seven hits and one run in seven innings, struck out six and walked one.
Posey spoiled things for Colorado again.
''He's hot right now,'' Dickerson said. ''We've got to figure a way to get him out.''
Gregor Blanco's infield single put San Francisco ahead in the bottom of the fourth before Dickerson tied it the next inning with his 20th home run.
Hudson joined CC Sabathia, A.J. Burnett and Bartolo Colon as the active pitchers with 2,000 or more strikeouts. Bochy became the 19th manager with 1,600 wins, passing Tommy Lasorda for 19th place on the all-time list.
''I'm lucky to be doing what I'm doing,'' Bochy said. ''It's been a tremendous ride.''
Rockies: Colorado placed LHP Boone Logan and catcher Wilin Rosario on the 15-day disabled list. Logan, on the DL for the third time this season, has left elbow inflammation for the second time and Rosario is nursing an inflamed left wrist. LHP Jorge De La Rosa is expected to make his next start - Sunday at Arizona - after bruising his left thumb while batting Tuesday.
Giants: Backup C Hector Sanchez is expected to miss the remainder of the season while recovering from a second concussion this year.
1B Brandon Belt still must rest for two more weeks with a concussion. He was away from the ballpark Wednesday after his wife went into labor. Shortstop Brandon Crawford didn't start to give him a break from what manager Bochy called ''general soreness.'' Crawford struck out as a pinch hitter in the ninth.
Rockies: RHP Jordan Lyles (6-1, 4.05) pitches the series finale in his first appearance against the Giants since Aug. 30, 2012. He makes his fifth start since spending a two-month stint on the DL with a broken left hand.
Giants: RHP Yusmeiro Petit (3-3, 3.59) starts in place of Tim Lincecum, who was moved to the bullpen after his recent struggles. Petit has retired 38 straight batters over his past seven appearances, six in relief. He is seven shy of the single-season record set by Mark Buehrle with the White Sox from July 18-28, 2009.
COLLEGE COMMISSIONER SIGHTING: Pac-12 Commissioner Larry Scott was part of the sellout crowd of 41,071.