Farrelly is an anglicised form of Ó Faircheallaigh, a family name of the Irish nobility from County Cavan. The patronym means "descendant of Faircheallaigh", whose name means "super war". Faircheallaigh was the son of Ailill, a 7th-great-grandson of Niall, King of Ireland. He was made the heir of Saint Máedóc of Ferns in the 7th century and his Ó Faircheallaigh descendants were the Abbots of Drumlane for 7 centuries until David Ó Faircheallaigh became Bishop of Kilmore. The surname was anglicised on emigration across the Anglosphere, where Major Patrick Farrelly (m.
https://en.wikipedia.org/wiki/Farrelly