Hansen and reporter Erik Ohlsson from Dagens Nyheter newspaper were embedded with Kurdish Peshmerga fighters who are attempting to remove the so-called Islamic State from Mosul.
As the group advanced on Sunday, Hansen moved ahead and was shot first on the helmet and a second time in the back.
He escaped serious injury as most of the force of the bullet was taken by the bulletproof vest he was wearing.
“I had an amazing guardian angel,” Hansen told Dagens Nyheter. “The bullet just hit the fleshy part of my back.”
Peshmerga fighters took Hansen to a hospital, where a bullet was removed from his back successfully.
Hansen is an award-winning photographer, who has covered conflicts before. He spoke to Radio Sweden in 2013 about the World Press Photo award he won for a picture of Gazans carrying two children and a father killed in an Israeli air strike.