By Humphrey Malalo

NAIROBI (Reuters) - Kenya's Supreme Court on Monday ordered a partial recount of ballots from the March 4 presidential election after losing candidate Raila Odinga alleged there were more votes cast at some polling stations than there were registered voters.

A swift and transparent resolution of the dispute that has unnerved the stock market is seen as critical to restoring the reputation of Kenya as a stable democracy after violence following the 2007 election left more than 1,200 dead.

This year's election passed peacefully though and went a long way to restoring Kenya's image. International observers said the voting was broadly credible, but the count then went for five days and monitors did not follow the entire process.

Odinga has said there was "rampant illegality" in the first-round victory of his long-term rival Uhuru Kenyatta. The son of Kenya's founding president, Kenyatta said the voting was "free and fair".

Adjudicating between the two political heavyweights is seen as a major test for the country's reformed judiciary.

Chief Justice Willy Mutunga has repeatedly said the Supreme Court would handle the dispute fairly.

"We shall render our judgment without fear or favor of anyone or anything, devoid of ill-will towards any persons or affection towards any cause that is partisan, unconstitutional, or illegal," Mutunga said at the start of Monday's session.

"In the end, you must trust us to do our job."

Monday was the first of two days of pre-trial hearings. The Supreme Court said the main hearings would be held on Wednesday and Thursday. By law, the court has till Saturday to rule.

The Supreme Court's verdict on the case is final, and both Odinga and Kenyatta have said they will abide by its decision.

Kenyatta, who faces charges of crimes against humanity at the International Criminal Court related to violence after the 2007 vote, won 50.07 percent of votes cast. He was well ahead of Odinga's 43.28 percent but secured only marginally more than the 50 percent needed to avoid a second round run-off.

The challenge could prolong uncertainty in east Africa's largest economy if a fresh election is ordered.

The court ruled that the presidential results in 22 polling stations be recounted and forms indicating official results in all 33,400 polling stations be scrutinized for accuracy. The court said the recount should be concluded by Wednesday.

"The re-tallying of the presidential votes in 22 polling stations will make this court establish whether the number of votes cast exceeded the number of registered voters," Justice Smokin Wanjala said on behalf of the six-judge bench.

The pre-trial meeting starts a week of hearings for the petition filed by Odinga and two other petitions filed by civil organizations, challenging the results released by the Independent Electoral and Boundaries Commission.

(Writing by James Macharia; Editing by Edmund Blair and Jon Hemming)