Labour's Patrick Nulty has been elected as a TD for Dublin West. It is the first time in 30 years that a government party has won a by-election.
Nulty takes the seat of the late Brian Lenihan.
Patrick Nulty led from the get-go in the Dublin West count, but it was a long wait to the final declaration.
It finally came in the early hours after a four-hour recheck prompted by the Socialist Party that ended in a dead heat between their candidate Ruth Coppinger and Fianna Fáil's David McGuinness.
Each had almost 10,000 votes. Coppinger was eliminated because she was outpolled by McGuinness on the first count.
Fine Gael's Eithne Loftus who came in fourth.
Patrick Nulty's win gives Labour a second seat in the constituency alongside Minister Joan Burton. It leaves Fianna Fáil with no TDs in the capital.