Skipper O'Hanlon held his nerve to seal a 5-3 penalty shoot-out victory for Paul Ince's League Two side after Dan Harding had missed his spot-kick for Town.
The Dons, who hit the woodwork three times, had raced into an early 2-0 lead thanks to Leon Knight's strike and Alex Bruce's own goal.
But Alan Lee's penalty and Kieron Murphy's own goal drew the Tractor Boys level before Kevin Gallen's 120th minute spot-kick took it to penalties after Owen Garvan had put Town 3-2 up in extra-time.
The re-shuffled Dons dominated the first half and Knight capped a superb passing move by deservedly putting them ahead in the 16th minute.
Aaron Wilbraham slipped a well-weighted pass down the right channel to Alan Navarro, who cut the ball back perfectly for Knight to ram in his first goal of the season from eight yards.
And then Ipswich centre-half Bruce's comical own goal gifted Milton Keynes a 2-0 lead just five minutes later.
The lacklustre Tractor Boys upped their game towards the end of the first half and Lee pulled a goal back from a controversial penalty on the stroke of half-time.
Dons striker Knight was unlucky soon after the re-start when his cheeky ten-yard back-heel was hacked off the line by Town skipper Jason De Vos.
But Murphy's own goal at the other end gifted Ipswich an equaliser to make it 2-2 sevens minutes after the break.
Ipswich substitute Danny Haynes was denied by a super double-save from Dons keeper Nathan Abbey three minutes from the end as the game finished 2-2 after normal time.
Garvan's header from substitute Haynes' cross put Ipswich ahead eight minutes into extra time, but substitute Gallen's last-gasp spot-kick drew the Dons level after Knight had been dragged down in the box by De Vos.