He was born in Bergen. He studied medicine at the University of Christiania (now Oslo), gaining his degree in 1866. He served a brief internship at the National Hospital in Christiania and as a doctor in Lofoten. In 1868 Hansen returned to Bergen to study leprosy while working with Daniel Cornelius Danielssen, a noted expert.
Leprosy was regarded as largely hereditary or otherwise miasmic in origin. Hansen became convinced of a specific cause and took the leap of considering a bacterium as the agent. In 1870-71 Hansen travelled to Bonn and Vienna to gain the training necessary for him to prove his hypothesis. In 1873 he announced the discovery of Mycobacterium leprae in the tissues of all sufferers, although he did not claim that they were bacteria, he received little support.
In 1879 he gave tissue samples to Albert Neisser who successfully stained the bacteria and announced his findings in 1880, claiming to have discovered the disease-causing organism. There was some conflict between Neisser and Hansen, Hansen as discoverer of the bacillus and Neisser as identifier of it as the etiological agent. Neisser put in some effort to downplay the assistance of Hansen. Hansen's claim was injured by his failure to produce a pure culture in an artificial medium or to prove that the rod-shaped organisms were infectious. Further Hansen had attempted to infect a least one female patient without consent, although no damage was caused that case ended in court and Hansen lost his post at the hospital.
Hansen remained medical officer for leprosy in Norway and it was through his efforts that the leprosy acts of 1877 and 1885 were passed, leading to a steady decline of the disease in Norway from 1,800 known cases in 1875 to just 575 cases in 1901.
Hansen had suffered from syphilis since the 1860s but died of heart disease.
In Bergen, Norway a medical museum has been designated Hansen, which is often referred to as the leprosy-museum. The University of Bergen has also dedicated a research facility to him - Armauer Hansen Building - located at Haukeland University Hospital in Bergen.