Motorcycle taxi driver Juacelo Nunes de Oliveira was at a party in a bar in the city of Agua Branca, in northeastern Piaui state, last Sunday when he got into an altercation.
The 39-year-old was stabbed four times, three times in the torso, with one wound perforating a lung, and once in the head.
He was first taken for treatment at a nearby hospital before being transferred to the Emergency Hospital of Teresina, a city 100 kilometers (62 miles) away -- with the knife handle protruding from his head all the while.
"It took him nearly three hours to arrive here at the hospital," Dr. Gilberto Albuquerque, general surgeon and hospital director, told CNN on Friday.
"He had the knife lodged in his head for this whole period but he was not aware of it," he said. "We believe the shock and a bit of the drinking may have helped him not to understand the knife was still in his head."
Pictures released by the military show Oliveira lying on a hospital trolley with what looks like a kitchen knife embedded in his skull up to the handle, just to the side of his left eyebrow.
According to Albuquerque, the knife stopped only when it got stuck in the man's lower jaw.
Oliveira was very lucky, he said -- and not just to be alive.
"The knife crossed his head just behind the optical nerve, got very close to the olfactory nerve and (was) just a fraction from the gustatory nerve. He could have been blinded and could have lost his senses of smell and taste, but none of that happened and he is alive and healthy."
The surgery to remove the knife was very delicate, since any slip could have breached arteries and led the patient to bleed to death, Albuquerque said.
It took the hospital surgery team two and half hours to complete, and was considered to be a success.
"He left the hospital yesterday, five days after coming in with a knife in his head," Albuquerque said. "He is healthy and perfect and he had no ill after-effects."