O'Brien was born in Calais, Maine in 1842. His family moved to Saint Anthony Falls, Minnesota in 1857. He enlisted in the 1st Minnesota Infantry, Company E, as a private on August 13, 1861. With this regiment, O'Brien saw combat in multiple engagements, including the Battle of Ball's Bluff, the Battle of Harpers Ferry, the Siege of Yorktown (1862), the Battle of Malvern Hill, and many others. He was also involved with the Battle of Gettysburg from July 2 to 3, 1863. On the second day, O'Brien helped rescue a fallen soldier and brought him back to safety. On July 3, during Pickett's Charge, O'Brien took up the colors of his regiment when the initial color-bearer was shot down, and in doing so received two wounds in a bayonet charge that followed to bring the flag back to safety. He received the Medal of Honor for these actions.