The victory after four qualifiers moved Ireland on to four points but they are still struggling in fifth place in Group D six points adrift of leaders Germany and Czech Republic.
Ireland took the lead thanks to an own goal in the seventh minute after a free kick from forward Andy Reid was deflected into the net off Davide Simoncini.
Kevin Doyle, playing only his fifth international, made it 2-0 in the 24th minute with his first goal for Ireland as he headed the ball against the underside of the bar and into the net off a cross from Kevin Kilbane.
It was another pass from Kilbane just seven minutes later that set Tottenham Hotspur's Robbie Keane up nicely for the first of his goals and put Ireland 3-0 up at halftime.
San Marino finally got a shot on target just after the break but Ireland goalkeeper Shay Given, back from injury, easily blocked captain Andy Selva's effort.
A second Keane goal in the 58th minute put Ireland 4-0 up as he comfortably drove home a penalty after Paul McShane was felled in the area.
The man-of-the match scored his third goal with a header in the closing minutes after a cross into the penatly area from Andy Reid found Keane unchallenged in front of the net.
Ireland may have expected to score more goals, however, against a side that lost 13-0 to Germany in September.
"We scored five, could have been more, bit sloppy at times, but it's been a professional job, that's all we could do," Ireland manager Steve Staunton told broadcaster RTE.
They will be happy, though, with a win that was crucial to their qualifying chances after a humiliating 5-2 loss to Cyprus in October led to calls for Staunton to quit.
The pressure on him eased later that month with a 1-1 home draw against Czech Republic but Ireland are still languishing just a point ahead of Wales who have a game in hand.
Staunton said Wednesday's result was all the more pleasing given Germany had only scraped a 1-1 draw in Cyprus.
"I always knew there'd be points dropped along the way. It's come a little bit early maybe for them but who knows. There's a long way to go, I've said it all along, and we just have to keep battering away and picking up points."