Only one point and one place had separated these sides in the play-off berths, but it was West Ham who had the better of the early chances as both Marlon Harewood and Defoe came close to breaking the deadlock with fierce 18-yard crackers.
Midway through the half, however, the flapping David James was almost left with the blues as the consequently injured Shefki Kuqi's aerial strength saw him win an up and under and the red-faced Hammers' keeper's blushes were only spared by Ian Pearce's goal line clearance.
While Ipswich continued to look dangerous on the break, Kelvin Davies remained the busier of the two goalkeepers and when Harewood's fancy footwork set up David Connolly the Irish striker's deft flick came within inches of giving the home side an interval lead.
Four minutes after the break, though, Harewood hurried down the right once more and this time another inch-perfect delivery into the six-yard box enabled Defoe to clinically side-foot home his 14th goal of the season.
Royle responded by pitching Counago into the fray and the Spanish sub was soon causing problems, as the card collecting Tomas Repka picked up his tenth booking of the season for cynically chopping him down.
Then on 70 minutes Counago was sandwiched by Kevin Horlock and Hayden Mullins as he danced his way into the box and, after dusting himself down, he sent James the wrong way with a cool spot-kick into the bottom right hand corner.
Having just salvaged one point, it only took another seven minutes for Counago to bag all three when, under pressure from Repka, he diverted fellow substitute Martijn Reuser's low 20-yarder past the static James.