Filling in for injured second baseman Juan Uribe, Ramirez provided the hit of the game.
"He's made the adjustment really well," said Guillen, the White Sox skipper. "He works a lot. If he continues with the bat like that, he'll get more playing time."
San Francisco had a baserunner aboard in every inning against White Sox starter Gavin Floyd (4-2), who withstood each threat and bounced back from a May 11 loss at Seattle in which he lasted only 3 2/3 innings.
The right-hander allowed four hits over six innings and didn't give up an earned run for the fourth time in eight outings this year. He struck out three and walked three.
Four relievers finished the five-hitter for Chicago's fourth shutout, with Bobby Jenks getting three outs for his ninth save in 11 chances. The Giants were blanked for the third time.
Ramirez, a rookie who defected from Cuba last November and has the nickname "Cuban Missile," had only three hits in his previous 27 at-bats (.111) before connecting off Giants starter Jonathan Sanchez (2-3) with two outs in the seventh and Nick Swisher aboard on a single.
"I feel very lucky," Ramirez said through a translator. "First of all, I work very hard. I do regular training and I've received a lot of support from my family. I want to keep helping this team."
The ball, which landed in the left-field bleachers, was thrown back onto the field before a catcher in the Giants' bullpen tossed it into the seats nearby. Then, White Sox third base coach Jeff Cox walked over and retrieved the ball for Ramirez.
"I just made one mistake, one pitch. That was the game," Sanchez said. "I thought Swisher was going to hurt me more than Ramirez."
The teams met for the second time since interleague play began in 1997. The Giants took two of three in Chicago from June 10-12, 2003.
Guillen and Giants skipper Bruce Bochy were winter ball teammates in Guillen's native Venezuela.
San Francisco's Randy Winn hit his 300th career double in the fifth for an 11-game hitting streak. He has hit safely in 13 of 14 games in May and is batting .373 (22-for-59) for the month. Ray Durham had a double among his three hits but the Giants missed opportunities with runners in scoring position and lost for the 10th time in 14 games.
"I don't think we're playing terrible," Winn said. "We just had some missed opportunities in key situations. At times we've been good at it and at times we've struggled. That's the thing when you're not a power team that you have to do."
Sanchez's winless stretch reached four starts. The left-hander hasn't won since beating Cincinnati on April 25.
A.J. Pierzynski, the Giants' catcher in 2004 before joining the White Sox, was booed at every opportunity in his first trip back to San Francisco's waterfront ballpark since he played here. He said afterward that one Giants employee said to him, "you ruined the organization."
Pierzynski tripled in the sixth for his first triple since Aug. 22, 2004, while with the Giants against the New York Mets. It was his third in San Francisco.
But the White Sox failed to capitalize, with Sanchez striking out Jermaine Dye swinging to end the inning.
"How many people they hold here? I hope 45 (thousand) show up today and they can boo A.J.," Guillen said. "We get used to it. We boo A.J. when he takes batting practice. I think A.J. loves that. Every time they do that he has a good game."
Swisher also returned to the Bay Area after playing his first four big league seasons across San Francisco Bay with the Oakland Athletics.
"It's great. I'm loving it," Swisher said of working in the Windy City.
- A day after the first-pitch temperature was an unusually high 95 degrees, it cooled down to 82.
- Floyd plunked Aaron Rowand in consecutive at-bats.
- Chicago went 2-7 in National League parks last year.
- Uribe missed the game with a slight right hamstring strain that forced him to leave Thursday's game against the Angels. Guillen expects him to sit out Saturday night but be available as a defensive replacement and perhaps return to the lineup Sunday.
- Pierzynski has a nine-game hitting streak.
- The Giants recognized former pitcher Masanori Murakami (1964-65) for Japanese Heritage night. He was the first native-born Japanese player in the majors.
- A local Little League team called "Dye Hard" sponsored by Dye will attend Saturday's game.