Born in Baltimore, Maryland, O'Brien attended the common schools and pursued classical studies in the old St. Mary’s College of Baltimore. He studied law, and was admitted to the bar in 1858, commencing practice in Baltimore.
He was elected as a Democrat to the Forty-third and Forty-fourth Congresses, serving from March 4, 1873 until March 3, 1877, but was not a candidate for renomination in 1876.
After Congress, O'Brien resumed the practice of law in Baltimore, and was appointed in 1901 and elected in 1903 as judge of the orphans' court of Baltimore, serving in that capacity until his death in Baltimore in 1905. He is interred in Bonnie Brae Cemetery.