Felix Byamukama pleaded guilty to a number of wildlife offences committed at Bwindi Impenetrable National Park.
The gorilla, a male named Rafiki, was reported missing on 1 June and was found dead the next day.
Two days later, Byamukama was arrested with several hunting items, including a spear and snares, according to a statement from the Uganda Wildlife Authority.
Rafiki - "friend" in Swahili - led the Nkuringo troop of more than a dozen gorillas.
The troop has been popular with visitors for decades, according to the New York Times.
Dr Gladys Kalema-Zikusoka, chief executive of Conservation Through Public Health NGO, said that the killing was unintentional.
She added: "He may have got scared, because he has never been that close to a gorilla, and for Rafiki he does not know a difference between a good person and a bad person, and so this person speared Rafiki out of fear.
"I really don't think that Rafiki attacked him, although he says that he was attacked and he speared him in self defence.
"So it is very unfortunate that, instead of avoiding Rafiki, he ended up killing Rafiki.
"But what he went to do was not poach gorillas like Rafiki, because people in Uganda don't eat gorillas.
"What he went to do was collect, to poach other animals which, like the bush pigs and daika - which is small antelope - to eat and when he went to get them is when he came across Rafiki."
Mountain gorillas are endangered and there are around 1,000 of them in protected areas in Congo, Uganda and Rwanda.