Michael D-Day: Higgins storms to victory after late vote switch
But the referendum on cutting judges pay will be passed easily.
From early yesterday it was obvious Mr Higgins was romping to a victory -- and secured just more than 700,000 votes on the first count -- an extraordinary reversal of fortunes after substantially trailing Mr Gallagher in the polls with just days to go.
Mr Higgins last night declared that he was "very happy" as he arrived in Dublin Castle in time for the announcement that he had topped the poll with 39.6pc of the vote.
"I feel a little overwhelmed. It is something I have prepared for.
"It's something I thought about for a long time," he said.
After throwing away his enormous lead in the polls in the closing days, Mr Gallagher congratulated Mr Higgins on his victory and said he had no regrets about running.
"None, whatsoever. It's a great thing in Ireland, that anybody like me, an ordinary person, can step forward and run," he said.
Finishing in third place, Sinn Fein's Martin McGuinness admitted he lined up the question to Mr Gallagher on RTE's 'The Frontline' debate about contacts with a convicted fuel smuggler over a €5,000 donation, which turned the election on its head.
"I knew absolutely that question had to be asked," he said.
Mr McGuinness' intervention came after the Irish Independent revealed Mr Gallagher's role in organising and attending the fundraiser with former Taoiseach Brian Cowen.
Fine Gael's Gay Mitchell barely finished a miserable fourth in the race, just ahead of Independent David Norris.
Fellow Independent Dana Rosemary Scallon edged out Mary Davis to avoid finishing last.
After a gruelling campaign for all the candidates, the outcome of the election changed dramatically in the closing days.
The fallout from the controversy surrounding Mr Gallagher's Fianna Fail past influenced how over half the electorate voted in the presidential election, polling data shows.
A whopping 28pc of voters switched first preference in the final week of the campaign.
Of these, 58pc deserted Mr Gallagher and moved largely en masse to Mr Higgins.
Just over half of voters chose who to vote for in the final 10 days of the campaign.
Fine Gael ministers admitted to being disappointed by the result and senior party figures said lessons had to be learned from its worst ever presidential election result.
"Any day you lose as badly as we did is a bad day for the party. This is a wake-up call for people in the Fine Gael parliamentary party that the hard-won gains of February 2011 shouldn't be taken for granted," a senior minister said.
Mr Mitchell only took 12pc of the vote in Dublin South-Central, the constituency he represented for over a quarter of a century.
The party's misery was compounded by a fourth place finish in the Dublin West by-election, where the Fine Gael candidate Eithne Loftus performing poorly.
Labour's Patrick Nulty was on course to take the seat in the Dublin West by-election last night, despite a late call for a full recount by the Socialist Party.