With the score tied 2-2 in the eighth, the Marlins put two runners on with none out against Rafael Dolis (0-1) and Ramirez followed by belting a 3-1 pitch deep over the left-center field fence.
The blast made a winner of Steve Cishek (1-0), who pitched a scoreless top of the eighth in relief of Josh Johnson, who held the Cubs to two runs on seven hits over seven frames.
Emilio Bonifacio went 2-for-2 with an RBI in a contest that saw the return of Marlins Manager Ozzie Guillen following a five-game suspension for making supportive remarks about former Cuban dictator Fidel Castro.
Cubs starter Ryan Dempster pitched well, surrendering only two unearned runs on four hits over six innings.
Darwin Barney went 3-for-4 with a run scored for Chicago, which fell to 3-8 in its first 11 games.