Fianna Fáil councillor Cormac Devlin has narrowly won the party's dramatic selection convention in Dun Laoghaire.
Mr Devlin defeated Ms Hanafin by four votes but only after he benefited from transfers after councillor Kate Feeney was eliminated.
Ms Hanafin was ahead of Mr Devlin after the first count at the convention in Killiney Castle.
But after Ms Feeney's transfers were distributed, Mr Devlin was announced the winner by 68 votes to 64.
It brings to an end a bitter battle for the nomination in the constituency.
Tensions among the trio further rose last week when Devlin - tipped to get the nod at the selection convention - warned party bosses that he would consider legal action if a diktat was issued from headquarters instructing delegates to select a female candidate - a form of “gendermandering”.
Speculation had mounted in recent weeks that Dún Laoghaire would receive a gender quota diktat from the party’s national constituency commission (NCC) following on similar instructions given to Dublin Central and Dublin South Central. Fianna Fáil have yet to hit the 30pc gender quota target required to avoid financial penalties. However, no such ruling was applied to the ever-controversial constituency, although party leader Micheál Martin denied this weekend that the legal threat by councillor Devlin had “no impact whatsoever” on the decision.
Around 170 party members arrived at the Fitzpatrick Castle Hotel this evening for the proceedings which were chaired by senator Thomas Byrne.
The race for the coveted nomination re-ignited the contest dubbed the Battle of Blackrock, when Kate Feeney and Mary Hanafin went head-to-head to secure the party’s nomination for the local elections, In the end, both women ran for Fianna Fáil and both were selected.
Although Dún Laoghaire-Rathdown is a four-seat constituency, it’s effectively a three-seater, as sitting TD and Ceann Comhairle Sean Barrett will be automatically re-elected to the next Dáil.
As Mr Devlin has won the nomination, party bosses now have the option of adding another candidate to the ticket. And as Fianna Fáil has under 23pc of female candidates to date, either Mary Hanafin or Kate Feeney may yet get the nod.
Meanwhile, Fianna Fáil completed its selection convention in Louth this evening.
Councillor Declan Breathnach and solicitor Emma Coffey were selected. Louth is a five seat constituency.
Meanwhile, Fine Gael minister Dara Murphy - under fire over the garda 'lift' controversy - has been selected at FG convention in Cork North Central.
However he won by just 16 votes out of a total of 350 counted.
More to follow