Councillor Cormac Devlin triumphed in a three-way battle with Ms Hanafin and fellow councillor Kate Feeney.
Ms Hanafin could yet be added to the ticket by Fianna Fáil high command as the party is struggling to reach the gender quota calling for 30% of candidates to be women. Mr Devlin edged out Ms Hanafin in a final score of 67 to 64 .
Ms Hanafin won a council seat in last year’s local election despite leader Micheál Martin trying to get her to quit the contest.
The selection of the constituency’s Dáil candidate has also caused controversy, as unlike two other Dublin seats, the party’s national constituency commission did not ban male candidates in order to comply with gender quota targets.
With some 190 party members eligible to vote in what was expected to be a tight contest, the decision to bring the selection meeting forward raised eyebrows, as it meant 10 people backing Ms Feeney were ineligible to vote as they had not been in Fianna Fáil for a full year.
With Ceann Comhairle Seán Barrett a TD for the constituency who is automatically re-elected, only three other seats are in play in Dún Laoghaire.
Private polling showed Ms Hanafin had the best chance of Fianna Fáil landing a seat in the constituency.
Mr Devlin threatened legal action against Fianna Fáil top brass if they tried to ban male candidates from the selection process.
In the end, the national constituency commission did not insist on a female candidate, but decided only one person would be chosen to run at the vote. This led to speculation that Fianna Fáil HQ might add Ms Hanafin to the ticket at a later stage.
Such a move would not have the backing of Ms Feeney who has said only one candidate should be fielded at the general election.
Fianna Fáil is the only major party to fail to achieve the required quota so far. Any party that fails to reach the target faces having half of its public funding cut after the election.
Taoiseach Enda Kenny has signalled that the election, which must be called by April at the latest, will be held in February or early March.
However, some in Fine Gael are urging a snap November election to cash-in on any “feel-good factor” emerging after a less severe October budget.
In Louth, Fianna Fáil selected Declan Breathnach and Emma Coffey to fight the general election.