A group of almost 30 armed civilians belonging to the same clan attacked soldiers in the camp on Tuesday, leading to a firefight in which three soldiers were killed, Somaliland's Defence Minister Ahmed Haji Ali told the BBC's Somali service.
After being arrested, 28 people were held overnight - and the military trial held the following day. Five minors were also given life sentences, after seven people - including three soldiers - were killed, a Somaliland official told the BBC.
Three people were acquitted, and the trial of three others postponed because they had been injured during the fighting. The civilians had confessed and an attack on Somaliland's military carries a mandatory death penalty for adults, the chairman of the military court, Yusuf Farah, told the BBC.
The BBC's Mohamed Mohamed says activists in Somaliland are likely to raise questions about the swiftness of the case - and whether the civilians had been properly represented. If the death penalties are carried out, there could be a backlash from other members of the clan involved and they may even resort to violence, our correspondent says.
Land disputes are common and often complex in Somaliland, he adds. Somaliland unilaterally declared independence in 1991 after the overthrow of Somali military dictator Siad Barre. It is relatively stable and holds regular elections, which have seen peaceful transfers of power.