Bruno Coutinho shot himself through the eye with his speargun when he was cleaning the weapon at his home in Petropolis.
X-rays show how the six inch harpoon passed through his left eye and into his skull.
Coutinho called for help and was taken to the Santa Teresa hospital where he was treated for the wound.
One neighbour told Sky News: "There were people who saw it and got frightened. A thing like this you only see in a movie."
Surgeons spent four hours and two surgeries removing the harpoon - it had been stuck in Coutinho's head for over 10 hours.
Although he has lost sight in his left eye, he suffered no permanent brain damage.
Coutinho is a full time PhD student at the Federal University of Rio de Janeiro studying computer graphics.
Orlando Maria, chief of neurosurgery at the hospital said Coutinho had had a lucky escape, as the weapon was just millimetres away from piercing a major artery in his head.
The object, it seems, took a path where it didn't damage any vital structures, any vascular structures and was taken out," he said.
Coutinho has been in hospital since the accident on 14 April but is expected to be released in the coming days.