Both sides had penalty shouts for handball turned down in a busy first half at Stade Velodrome but the game had slowed to a crawl by the time Ramsey coolly slotted past Steve Mandanda with seconds remaining.
Ramsey had started on the bench due to concerns over a hamstring problem but was in the right place to continue his side's unbeaten run in Europe.
They now lead OM seven points to six and, in contrast to their faltering league form, are in control in Europe.
Things started nervily, with just four minutes gone when Alex Song mis-controlled the ball under pressure from Loic Remy, who briefly looked as though he would have a clear run on goal.
A foul from Song stopped him in his tracks and the subsequent yellow card was a price worth paying.
Marseille still had a dangerous free-kick to show for the error, but Mathieu Valbuena handed Wojciech Szczesny a simple save.
Arsenal put together a nice move of their own in the 10th minute, Song, Mikel Arteta and Theo Walcott combining to offer Robin van Persie a first sight of goal, though his header wide was rendered irrelevant by an offside flag.
Benoit Cheyrou caught Arsenal off guard at a throw-in when he chipped toward goal, but his attempt continued over the crossbar.
Marseille were in the ascendance and had a strong penalty appeal for handball turned down when a cross struck Carl Jenkinson's arm.
The referee rejected the claim and promptly booked Andre Ayew for his reaction.
With 20 minutes gone Arsenal started to hit back and won a corner after a threatening run by Arteta was cut short by Nicolas N'Koulou's challenge.
Arteta's delivery from the left looked to have been handled too, this time by Souleymane Diawara, but once again there was no penalty decision. Instead, the ball found Van Persie and the Dutchman's looping header would have gone in were it not for Diawara, who was back in position to clear the danger legally.
The Gunners had visibly raised their game but a quick counter-attack nearly gave the hosts a 31st-minute lead.
Remy skipped past Per Mertesacker on the byline and shaped to cut in on goal, only for the covering Jenkinson to get a deflection on a shot that squirmed wide of the far post.
OM had other chances to break the deadlock before half-time, Laurent Koscielny making a last-ditch tackle on Remy and Lucho Gonzalez diverting Valbuena's cross just off target from close range.
Andre Santos, booked earlier for a body check, was fortunate to avoid a second yellow card just before the break when he needlessly pawed at the ball.
Arsenal looked to feed the ball wide to Andrey Arshavin as the second half got under way, but he was having little luck getting past Marseille right-back Cesar Azpilicueta.
It took a clever exchange of passes with Santos for the Russian to finally get away down the left but there was little support and the best he could manage was a tame centre.
Arsenal's back line made a meal of clearing Remy's 57th-minute cross, Jenkinson, Mertesacker and Song all trying - and failing - to get the ball away.
Gonzalez and Ayew were both hustling but neither had a clear shot on goal before Jenkinson finally launched upfield.
It was his last act before being replaced by Johan Djourou in some discomfort.
With 63 minutes gone, the quiet Walcott caught N'Koulou in possession inside the penalty area but could not beat Mandanda at his near post.
The England winger, short of inspiration and service, made way for Gervinho soon after.
Marseille boss Didier Deschamps also looked to his bench, replacing Remy with the fit-again Andre-Pierre Gignac with 20 minutes to go, but neither side looked overly keen to take a risk.
Gunners boss Arsene Wenger shuffled his deck again in the closing stages, moving the ineffective Tomas Rosicky to the left and sending on Ramsey to occupy the space behind Van Persie.
Some sloppy defending briefly alerted Gignac to a gap in the Arsenal line but he was outmuscled by the retreating Koscielny.
With moments remaining Djourou whipped a cross in from deep on the right touchline, with Gervinho failing to control it in the centre.
Instead, the ball found Ramsey arriving at the far post and his finish was enough to steal an unlikely three points.