Golden-oldie Dean Windass scored his first goal for Oldham, the 200th of his League career, as the Latics kept up their League One promotion bid.
Windass was making his seventh Oldham appearance since joining on loan from Hull and he broke his duck with a powerful header in the second-half.
It was the second time Northampton had conceded from a set-piece and their reply, a consolation goal from Adebayo Akinfenwa, proved too little, too late.
Dominant Oldham also hit the woodwork, wasted other openings and had two efforts cleared off the line.
They missed an early chance through Deane Smalley but broke the deadlock after eight minutes when Lee Hughes won a free-kick near the touchline.
Kevin Maher delivered a teasing free-kick towards the far post and centre-back Reuben Hazell headed beyond keeper Chris Dunn from eight yards.
Oldham stayed in control, with Maher drilling off target and Dunn forced into a smart save from Hughes.
They went desperately close on 35 minutes as Smalley charged into the box, only for Mark Hughes to appear with a spectacular goal line clearance.
Northampton's first real chance fell to Abdul Osman, who found space ten yards out but could only head over the bar.
Windass was then unlucky with two attempts on goal as he chipped inches off target and saw his bullet header scrambled off the line by Hughes.
Northampton keeper Dunn saved superbly from Neal Eardley before Windass made it 2-0 by rising to meet Maher's right-wing corner and planting his header just inside the post.
The 39-year old celebrated in style and was booked for taking off his shirt by referee Andy Haines.
Northampton halved the deficit seven minutes later as former Oldham man Andy Holt showed good skill down the left and crossed for Akinfenwa to convert a close-range header which squeezed through the dive of debutante goalkeeper Jan Budtz.
The Hartlepool stopper was signed on loan just hours before the game as emergency cover, due to Mark Crossley being on the long-term injured list and Greg Fleming serving a one-match ban.
Northampton tried to force an equaliser as Oldham showed nerves but they were forced back onto the defensive for the last ten minutes.
And only the woodwork denied Oldham a third goal as Hughes peeled away and saw his close-range header rebound off the post.