A court martial has found the former Sri Lankan armed forces chief, General Sarath Fonseka, guilty of engaging in politics while on active service.
Gen Fonseka would be stripped of his rank and medals once the government had ratified the decision, officials said.
He has been detained by the authorities since shortly after January's presidential election, when he failed to oust President Mahinda Rajapaksa.
The general and his supporters say the charges are politically motivated.
Gen Fonseka led the army in its victory last year against the Tamil Tigers and was hailed as a war hero by the majority Sinhalese community for bringing an end to 26 years of civil war.
He still faces a second court martial on alleged corrupt deals while in the army.
On Friday, officials said the general had been found guilty by a three-member panel and sentenced to a dishonourable discharge, pending the approval of President Rajapaksa as commander-in-chief.
"When an officer is cashiered, he loses the rank and all the awards and honours received as a military officer," the Sri Lankan presidential secretariat said in a statement.
One of Gen Fonseka's lawyer, Sunil Watagala, told the BBC's Charles Haviland that the case has been heard in the absence of the defence team during a court vacation.
Mr Watagala said it was irregular for a trial to be held now - but the court martial had rejected the defence proposal that it be held next week.
An aide to General Fonseka, Tiran Alles, described as "totally unacceptable" the holding of the trial during this period.
A few months after the Tamil Tigers' defeat, Gen Fonseka was promoted from army commander to chief of the defence staff by Mr Rajapaksa.
The two men clashed over who should take credit for the war, however, and Gen Fonseka is said to have seen this as an attempt to sideline him.
In November, he shocked many by announcing his retirement. Two weeks later, he declared his intention to run for the presidency.
Mr Rajapaksa beat him soundly to win a second term. Opposition parties claimed that the vote was unfair.
On 8 February, Gen Fonseka was arrested and taken into military custody. The government said he would be tried for "military offences".
It was later announced that he would face two separate courts martial for undertaking political activities before resigning from the army and for granting corrupt arms procurement contracts while in command.
He was then told he faced civilian trials for allegedly inciting unrest by quoting reports that accused the defence secretary of war crimes, and for recruiting army deserters to work on his election campaign.
He has been allowed to leave jail under military escort to attend parliament since April, when he was elected an MP for the opposition Democratic National Alliance (DNA). His parliamentary status will not be affected by the sentence.
Meanwhile, a court in the southern city of Galle has remanded supporters and two parliamentarians from the DNA until 16 August.
Parliamentarians Vijitha Herath and Ajith Kumara and the group are accused of assaulting the police after a rally demanding the release of Gen Fonseka on Thursday.
Police used tear gas and batons to disperse the crowd.