By Sui-Lee Wee

BEIJING (Reuters) - A court in China has sentenced a man to eight years in prison for trying to form an opposition party and for online messages criticizing the ruling Chinese Communist Party, a week ahead of a congress which will usher in a new generation of leaders.

The court in the southwestern city of Kunming sentenced Cao Haibo, 27, for "subversion of state power", his lawyer, Ma Xiaopeng, said. Cao had called for democracy and had tried to form a party called the "China Republican Party", Ma said.

The charge is more serious than one of incitement of subversion, which is more typically used against party critics.

The sentence signals the party's resolve to crack down hard on dissent, especially as it readies for a power handover at the congress which opens in Beijing on November 8.

President Hu Jintao is due to hand over his party chief position to anointed successor Xi Jinping.

Ma told Reuters by telephone that he thought the sentence was too harsh.

"Cao Haibo does not understand politics in China," Ma said.

"We think he's an immature child; he really did not know that the party would take it this seriously."

Ma said that Cao's party had only existed for one day online.

Cao, who was running an Internet cafe, is not a prominent dissident. Police cited Cao's text messages that he sent to friends using a popular messaging service, Ma said.

Ma said he told the court during the trial in August, which was closed to the public, that Cao did not deserve to be punished criminally.

Ma said he was informed of the sentence, which was delivered on Wednesday, on Thursday morning by telephone, instead of in court. He said that was illegal.

Calls to the Kunming Intermediate Court, which sentenced Cao, were not answered.

Cao's wife, Zhang Yan, confirmed that Cao was jailed for eight years. Zhang, 23, said she was surprised by the severity of the sentence.

"It exceeded our expectations, we only thought he would be sentenced to five years at the most," said Zhang, adding that she did not know the content of Cao's messages that were deemed subversive. They have a nine-month-old child.

Police arrested Cao in October 2011, said Zhang, about three months after she and Cao married. Zhang said she did not know if Cao would appeal but he would meet his lawyer next week.

The party has always moved swiftly to crush opposition t its 63-year monopoly on power. Defendants facing subversion charges in China's party-run courts are almost never acquitted.

(Editing by Ben Blanchard and Robert Birsel)