Ramirez, who was struggling with a .178 average going into the contest, cracked one of his homers in the three-run sixth inning and the other in the eighth to help give the Cubs their first back-to-back wins since they beat Oakland June 16-17.
Kosuke Fukudome had a solo home run for Chicago and Carlos Silva (9-2) broke a four-start winless streak, giving up two runs on four hits in six innings. Carlos Marmol went 1 2/3 innings for his 16th save of the year.
Barry Enright (1-1) took the loss, allowing three runs -- two on Ramirez's sixth-inning homer -- and seven hits in 5 2/3 innings. Kelly Johnson contributed a home run to the seven-hit Arizona offense.