Updated

Legislators chose an opposition member as parliament speaker in a close vote Tuesday, giving a victory to foes of Kenya's president as they prepared for mass protest rallies that raised fears of new violence over last month's disputed election.

Soldiers stood guard outside the National Assembly, and security forces were expected to be out in force Wednesday to guard against unrest with the start of three days of demonstrations against President Mwai Kibaki.

The legislative session was the first time that Kibaki and opposition leader Raila Odinga were together since Odinga accused Kibaki of rigging the Dec. 27 presidential ballot. The two arrived at the National Assembly at the same time but studiously ignored each other.

• Click here to view photos.

Kenneth Marende, a 52-year-old lawyer and opposition supporter, was elected speaker of the National Assembly in a narrow 105-101 vote over a Kibaki loyalist.

Although foreign and local observers say the tally of the presidential election was deeply flawed, they found no problems with legislative voting that was led by Odinga's forces and saw half of Kibaki's Cabinet lose their seats.

Odinga's Orange Democratic Movement won 99 seats in December's election and had to rely on help from smaller parties to win the speaker fight. Kibaki's party, which has only 43 seats, also rallied support from small blocs, indicating the potential for bitter fights in the body.

Marende's victory buoyed the opposition. While the speaker cannot directly block Kibaki's legislative agenda, he can slow it with his rulings and allow motions against the president's policies to be debated.

The contest for speaker was acrimonious, echoing the bitterness that set off widespread violence in Kenya after Kibaki was announced as winner of the presidential election. More than 600 people have been reported killed.

Odinga's legislators initially insisted voting for speaker should not be secret. "We went into (the presidential) election with secret ballots and you stole it," said William Ruto, a leading opposition figure.

The opposition finally agreed to go ahead with a secret ballot, as in past contests, but legislators from Odinga's party then objected to swearing an oath of allegiance to Kibaki, repeating their charges that he stole the election.

"Kibaki is a fraudster," lawmaker Ababu Namwamba said, noting that the Electoral Commission's chairman and five of its members have said there were problems with the vote tally.

Kibaki's side argued the oath was required both by the law and tradition.

The new speaker resolved the issue by ruling the law required legislators to swear allegiance to the president as an institution, not to a specific individual.

As lawmakers were being sworn in, one opposition member tried to pledge to serve "President Raila Odinga," but he was corrected by Marende and took the ordinary oath.

In Nairobi's Mathare slum, cheers broke out at news of the opposition's victory in the vote for speaker.

Earlier, more than a hundred opposition supporters scrawled graffiti on the shantytown's main street showing Kibaki in a coffin. When a group from Kibaki's Kikuyu tribe tried to pass the crowd, they were kicked and punched.

"The police will shoot tomorrow, but they don't have a bullet for each of us," said Cliff Owino as he picked up a lump of cement and threw it at a fleeing Kikuyu. "These will be our bullets. This is how the war starts."

Former U.N. Secretary-General Kofi Annan had been expected in the capital Tuesday night on a mediation mission, but the visit was postponed several days after he fell ill with "severe flu," his office in Geneva. It said he would head to Nairobi "as soon as feasible."