The detainees were arrested last year on charges of involvement in a coup attempt by Darfur rebel sympathisers, allegedly masterminded by the Popular Congress party of Islamist leader Hassan al-Turabi.
Defence lawyer Barud Sandal said however that Al-Hajj Adam Yusuf, initially suspected of being the plotters' leader and currently on the run, was acquitted for lack of evidence.
"The sentences are harsh and we will appeal," said the lawyer.
Twenty of the accused were sentenced to prison terms ranging between five and 15 years, while another five were also acquitted, three of them in absentia.
The only civilian among those sentenced Thursday is a lawyer, Suleiman Tumbul Haggar, said Sandal, who was himself detained in last year's government sweep before being released.