The victim, who was unaware of the seriousness of the situation at the time, went to hospital where they discovered the 35mm stainless steel staple was embedded in his brain.
Doctors, worried about the possibility of infection, were forced to operate on the man, the court heard.
The situation was classed as ''life threatening'', but the victim survived surgery.
Matthew James Varcoe (24), an aluminium joiner, appeared in the Dunedin District Court yesterday after pleading guilty to causing grievous bodily harm with reckless disregard for the safety of others.
Judge Michael Turner called the defendant's actions ''stupid and reckless'' and he stressed that the victim could have been killed.
''I'm sure you'll carry that thought with you for the rest of your life,'' he said.
According to court documents, Varcoe and the victim had worked together for more than two years.
On June 1, the pair were at work in the harbourside industrial area.
The victim was repairing a sliding door while Varcoe used a staple gun at his work station.
''There was some light-hearted banter between the victim and defendant which resulted in the defendant firing staples from a staple gun ... towards the victim and his co-worker,'' a police summary said.
As the staples only measured 15mm, they had no effect.
As the verbal jousting between the men became more pointed, Varcoe walked over and slapped the victim in the face.
''This resulted in a tussle between both parties which appeared to be light-hearted at first, with a lot of shoving and pushing, but the intensity increased and the defendant became more aggressive,'' the court heard.
Varcoe picked up a bigger staple gun, powered by a compressed-air line.
The victim grabbed at his arm as the defendant pointed the improvised weapon at him.
Varcoe, though, was able to press the gun against the top of his colleague's head.
The safety guard was disengaged. He pulled the trigger.
The 35mm staple penetrated the man's cranium and lodged in his brain.
It was the last time the pair spoke.
Varcoe lost his job and the victim struggled with the neurological complications stemming from the injury - fatigue and balance issues among a slew of problems.
''There was certainly no intent to cause the damage that was caused,'' defence counsel Andrew Dawson stressed.
Judge Turner accepted Varcoe's ''sincere remorse'' and sentenced him to seven and a-half months' home detention.
While he had considered adding further penalties, he eventually opted against it.
''You're a first offender. While there might be programmes available to you through community work that you can do on your own, there would be other times you might be rubbing shoulders with more seasoned offenders. The aim is to keep you out of the criminal justice system,'' he said.
The judge ordered Varcoe pay the victim $1000 in a lump sum and another $2000 at $15 a week.