Hudson (4-1) struck out six and didn't walk a batter for the fourth time in five starts this season. The Giants' most consistent starter in his first season with the club, Hudson has walked two batters in 46 innings.
The three-time All-Star was one pitch from recording his first shutout in nearly two years before Yasmani Grandal's two-out home run in the ninth.
Brandon Hicks homered and Michael Morse drove in his team-leading 20th RBI for the Giants, who finished 5-1 on their homestand.
Cameron Maybin doubled and scored for San Diego, which has lost 10 consecutive series at AT&T Park.
Hudson allowed only one runner past second base until Grandal's home run in the ninth, and had two stretches where he retired nine straight batters.
The right-hander helped his cause at the plate with a single in the second and a key sacrifice bunt in the seventh that put the eventual winning run in scoring position.
Hudson has pitched at least seven innings in each of his six starts this season, the longest streak by a San Francisco pitcher in his first year with the club since Livian Hernandez's six-game stretch in 2002.
Hudson was sharp early and needed only 19 pitches to retire the first seven batters. After giving up a one-out single to Jace Peterson in the third, the three-time All-Star struck out San Diego pitcher Robbie Erlin and Everth Cabrera.
The only other hits the Padres managed came on a two-out double by Grandal in the fourth, a single by Jedd Gyorko in the seventh and a leadoff double by Maybin in the eighth. Maybin scored on Alexi Amarista's groundout.
The Giants, playing without leadoff hitter Angel Pagan and third baseman Pablo Sandoval, backed Hudson with just enough offense. Every starter except leadoff man Juan Perez had at least one hit.
Hunter Pence singled, stole second and scored on Morse's two-out double off the wall in right in the first.
Hicks' fifth home run of the season leading off the second made it 2-0.
Erlin (1-4) pitched out of jams in the third and fourth but lost his fourth straight start. He left with two outs in the seventh, struck out five and walked one.
Buster Posey's RBI single off reliever Dale Thayer drove in Joaquin Arias to put the Giants up 3-0.
After Grandal's homer cut San Francisco's lead to 3-2, Romo retired one hitter for his seventh save.
Pagan was given the night off to rest his sore right knee while the slumping Sandoval also rested. Sandoval went into the night batting just .177 with only six RBIs.
Seth Smith went hitless in four at-bats in his return to the Padres lineup after missing four games with a strained groin.
NOTES: Gyorko was reinstated from the paternity leave list before the game. To make room, San Diego optioned Tommy Medica to Triple-A El Paso. ... Padres LF Carlos Quentin, on the 15-day DL with a bone bruise in his left knee, will re-join the big league club for a workout at Petco Park before Friday's game against Arizona. The team will then determine where Quentin goes to begin a rehab assignment. ... Giants RHP Matt Cain, who was scratched from Tuesday's start after slicing his index finger with a knife, isn't likely to throw again until the team begins a three-game series in Atlanta on Friday. ... RHP Tim Lincecum (1-1), who starts the series opener, has a 2.99 ERA in 13 career starts against the Braves. ... RHP Andrew Cashner, San Diego's starter against Arizona, has a 0.81 ERA at Petco Park this season.