After eight years of brutal dictatorship under Idi Amin and 18 months of chaos following his overthrow last year, Ugandans will vote Wednesday in a controversial election seeking to restore legitimate government in this despairing land.

Probably few parliamentary elections have been held in such unfavorable circumstances.

Former supporters of Amin are carrying on a sporadic guerrilla war in the remote northwest of the country, famine is devastating the northeast and some politicans have been assassinated as violence has become a norm of Ugandan life.

There is talk of the possibility of a civil war or coup after the election, sparked by tribal and religious differences in this former British east African colony of 12 million people.

Reflecting government nervousness, the international airport at Entebbe was closed tonight on the eve of the voting, with no reason given for the action.

Most of the Oregon-sized country's 4.8 million registered voters have never taken part in an election. The last one was held 18 years ago, shortly before independence and brought to power Milton Obote, the man who is expected to regain the presidency tomorrow.

Obote, 55, eliminated elections scheduled in 1967, established a one-party state and put the country on a socialist path, a course he says he has now abandoned. His military chief, Amin, overthrew him in 1971, wiped out all political organizations and embarked on a bloody eight-year rule in which it is estimated that half a million people were killed.

A ministry of information official who is openly pro-Obote told reporters today that the elections will mean Uganda is "moving near if not into a democratic world."

Not everyone agrees. The small Uganda Patriotic Movement, has called the election a "sham" and said it will not accept the results.

The only party with a chance to defeat Obote, the conservative, Catholic-dominated Democratic Party led by Paul Ssemogorere, says it is withholding its judgment until after the elections. All political organizations have issued charges of fraud and vote-rigging but most accusations center on Obote's party.

The military commission that ousted President Godfrey Binaisa last May, becoming the third government to rule within a year of Amin's overthrow, decidedly favors Obote. His party, the Uganda People's Congress (UPC), controls 21 of the 28 Cabinet ministries, including most of the key ones involved in the election, such as Information, Public Service, Justice and the Military.

The government fired 14 local election officials recently and replaced them with persons presumably favoring Obote.

The government-owned Uganda Times today ran a banner headline saying: "UPC Heads for Polls' Victory."

Most observers agree, however, that Obote's Congress party is far better organized than its opponents, which have compounded their problems through inefficiency.

Obote enjoys the support of Tanzanian President Julius Nyerere, who provided him asylum for nine years in Dar-es-Salaam while Amin ruled.

Nyerere still has 10,000 troops in the country to help maintain a semblance of order. They are the remnants of the 40,000-man force that drove Amin out in April 1979.

The Commonwealth, an association of Britain and its former colonies, has sent a team of observers at Uganda's request to monitor the elections and determine whether they are free and fair. The 42-nation organization carried out a similar function during the Zimbabwean elections earlier this year, and its evaluation helped to lend credence to the victory of Prime Minister Robert Mugabe.

All indications are, however, that the Commonwealth assessment, expected Thursday before final results are announced, will turn a blind eye to many of the Congress party's offenses and rule that the election was acceptable, given the prevailing circumstances in Uganda.

Anything short of that could make it difficult for the new government to restore respectability and gain badly needed international aid to rehabilitate the country.

Obote's party is already guaranteed 17 seats in the 126-member parliament, since opposition candidates have been disqualified or prevented from filing their nomination papers in as many districts.

In some cases, the Democratic Party charges that its would-be candidates were detained on nomination by the military, thus preventing them from filing. The Uganda Patriotic Movement says two of its candidates, a university professor and a Catholic priest, were disqualified for failure to demonstrate proficiency in English, the official language of the country.

The parties say they will go to court to declare the election in these districts invalid, but by the time there is a ruling the government should be well entrenched.

Apparently as an insurance measure, Paulo Muwanga, the chairman of the military commission, fired the country's chief justice, Samuel Wambuzi, last week. No reason was given, but under the constitution the chief justice calls on the leader of the winning party to form a new government.

If the election is close, it is possible that a judicial interpretation might be necessary to determine the winner because of an unusual clause in the 1967 constitution under which the election is being carried out.

The charter, under which Obote declared a one-party state and proclaimed himself president in 1969, stipulates that if two parties gain over 40 percent, the party that won the most seats in the previous parliament will name the president.

Since the Uganda People's Congress won the last election, it only needs to win 34 seats aside from the 17 uncontested ones to gain the necessary 40 percent of the 126 seats.

Emmanuel Debrah, the head of the nine-nation Commonwealth observer team and former Ghanaian ambassador to Washington, said the group is here "to see that people live up to their ground rules that they lay down. We can't tell them how to run their own business.

"If there is an injustice, I expect the parties to go to court," he said, addiing that "by and large the grounds are well-prepared to have good elections."