The new deal will see O'Neill, who succeeded Nigel Worthington in December 2011, remain in charge for the Euro 2016 qualifying campaign.
The news came shortly before O'Neill was due to name his next squad for this month's friendly against Turkey in Adana.
O'Neill said: "When I was appointed Northern Ireland manager I was honoured to have been chosen to manage my country and I am extremely happy to have agreed a new two-year deal with the Irish Football Association.
"I have said all along that I would like to continue in the role.
"I think there has been a major transition in the team - it's a very young squad, but a squad which has developed during the last campaign, with several young players of quality emerging.
"I am now looking forward to taking the team into the European Championship qualifiers."
O'Neill's side finished fifth in their six-team 2014 World Cup qualifying group and suffered a humiliating loss to Luxembourg along the way.
They have won just once in 14 matches under O'Neill but the Irish FA is convinced he is the right man for the job.
President Jim Shaw said: "I am delighted that Michael has agreed a two-year extension to his contract.
"I have no doubt that he will be able to build on the work he has already done and will take us forward in the Euro 2016 campaign.
"Michael is a true professional who has passion and pride - something which he showed as a player for his country and now as a manager and I believe he is the right man for the job of Northern Ireland manager."