The Uganda People's Congress, led by former president Milton Obote, won the East African country's first election in 18 years today. But the victory, tainted by charges of fraud, was immediately challenged by the rival Democratic Party.

The controversial election heightened political animosities, thus dealing a blow to hopes that an elective government would end rule by the gun in Uganda. The country has been battered by a decade of dictatorship under Idi Amin and chaos under three successor governments.

The Army, which mainly supports Obote, engaged in reckless firing of heavy and small arms last night, apparently as a show of strength and a warning to Obote's opponents to accept the election results despite widespread charges of fraud.

Tonight. the firing returned to almost normal: just a few hundred sporadic shots interspersed with an occasional burst of automatic fire in the deserted downtown.

More than 48 hours after final returns had been expected, several seats in Parliament were still not decided, but official figures gave Obote's party a majority of the 126 seats. Uganda Radio announced that the Uganda People's Congress had won 67 seats to 47 for the Democrats and one for a minor party.

Few people other than Obote supporters, however, thought the result was a fair reflection of the Ugandan electorate because of alleged abuses before and during the election and in the vote counting. The Democrats, who favor private enterprise more than Obote, are expected to file court challenges to the results for as many as 17 seats.

Under the circumstances, there were grave doubts that Obote would be able to end the violence, restore the economy and bring Uganda back to respectability after the bloodbath under Amin in which about 500,000 people were believed killed.

The Democrats, led by American-educated Paul Ssemogorere, issued a statement calling for fresh elections under an independent commission.

The party charged that election results were altered in seven areas of the country but gave no details of what was done. It also accused the Army and other officials of the military-backed government that favors Obote of intimidating Democratic Party agents, forcing them to leave the polls before ballots were counted.

In addition, the party said the government-appointed electoral commission was not independent or impartial and was responsible for gerrymandering of voting districts and registration irregularities.

The chief cause of scepticism about the results among many Ugandans and foreign observers was the unilateral takeover of the election process for a day by Paulo Muwanga, the chairman of the ruling military commission.

When Muwanga Thursday declared himself the sole judge of the validity of the returns and banned their publication, there were widespread reports that the Democratic Party had won a majority based on partial returns, although there were some doubts.

One day later, when Muwanga relented and returned the process to the electoral commission, the Uganda People's Congress had reversed matters and claimed victory, although just the day before the party headquarters was the scene of gloom.

Representatives from the Commonwealth, an organization of Britain and its former colonies, left Uganda today after observing the election but before Obote's victory became official.

The group issued a preliminary assessment Thursday that, although critical, concluded that the poll had "been a valid electoral exercise." However, the report was issued before Muwanga's temporary takeover of the process and the subsequent controversy over vote counting.

Many of the observers were openly critical of Muwanga's move, which is expected to come under strong attack in the final report to be issued next week from London.

Noting the slowness in announcing the final tallies, one observer said, "What I don't understand is why it's taking so long to fix the results."

Life slowly returned to normal today in Kampala, the capital, although most stores remained closed. The city of 400,000 people had been deserted for the last three days as residents either left to vote or in fear of violence. Kampala is a stronghold of the Democratic Party.

As Radio Uganda announcements of the results moved the Uganda People's Congress closer to victory, party members, many in red T-shirts emblazoned with Obote's image, took to the streets in celebration.

Announcement of the victory did not come until shortly after 2 p.m., but the military band rehearsing for Monday's inauguration gave away the long-expected result hours earlier.

As the band marched to Parliament, site of the inauguration, it played "Congress of the People," Obote's party anthem.