The bloodiest campaign in Jamaica's history ended tonight with the defeat of social democrat Michael Manley's 8-year-old government by the party of his relatively conservative opponent, Edward Seaga.

The hard-fought race has been watched closely by both the United States and Cuba, who see this largest English-speaking island in the Caribean as important to the future of the economically troubled region.

Manley, 56, a major figure in the movement of nonaligned nations, had attempted to maintain friendly relations with the United States, but at the same time he emphasized close relations with Cuban President Fidel Castro. Opposition leader Seaga, 50, the next prime minister, is outspokenly antagonistic to Havana and sympathetic to Washington.

The latest returns showed Seaga's party winning 53.4 percent of the vote compared to 46.6 percent for Manley's party. According to unofficial forecasts, the continuation jof that trend would give Seaga at least 50 of the 60 seats in the elected lower house of Parliament. Of 24 seats so far decided, Seaga's party won 17 and Manley's took seven. In districts where votes were still being counted, Seaga was leading in 34 while Manley was ahead in only two.

In a victory speech tonight, the Harvard-educated Seaga told cheering supporters he would form a "moderate government," and he called for the expulsion of the Cuban ambassador. He also told reporters that his first priority would be "the restoration of economic progress." It is expected that Seaga will form a new government Friday morning.

It is too early to predict, however, whether the new government will be able to bring an immediate end to the passionate, partisan violence that has bitterly divided this island nation and cost an estimated 500 lives since Feb. 3, when Manley called for early elections.

Although 80 percent of Jamaica's nearly 1 million voters were expected to go to the polls, they went in many cases facing murderous threats from zealots of both parties.

Seaga earlier made it clear his supporters would accept nothing less than victory. He made not threats if he lost a "fair" election, but denied that such a thing could happen. Although he ultimately triumphed today, he was denouncing alleged fraud almost from the time the polls opened this morning.

This was the first election since independence from Britain in 1962 to be supervised by a bipartisan electoral commission.

Manley repeatedly has called on his supporters in the People's National Party to remain calm no matter what the outcome. But for many of his followers, convinced that socialism is their one chance of finding a future in this desperately poor country, the defeat of Manley is a bitter blow and could trigger retribution.

Manley's charismatic leadership, blamed by Seaga for most of Jamaica's woes, was believed by at least some of the outgoing prime minister's followers to be all that held his constituents back from open rebellion. Manley won massively in his past contests.

"These people are angry, real angry," said one gunman in Manley's party earlier this week. This afternoon in one of the most depressed and violent slums of Kingston, a heavily pro-Manley area known as Trenchtown, a young man said, "Michael can't lose, man. It's Michael, only Michael for us. No Michael and you got revolution."

"I can tell you, it's miserable whenit comes to this time," said a local Manley organizer of the virtual warfare that has existed between Trenchtown and the nearby Seaga slum constituency known as Tivoli Gardens or "Back-o-Wall."

Throughout the day there were sporadic gunfights in the rougher sections of the city. Official police counts list two people dead, but workers in the city's morgues said they had received at least a dozen bodies in the course of the afternoon.

The Kingston Public Hospital emergency room was filled with wounded early this evening. Several were children hit by stray bullets.

Twelve-year-old Angel MacKenzie lay semiconscious on a hospital cart, a bullet through his shoulder. He had been playing at his aunt's house and had been running home near a polling station when shot's rang out.

"I'm glad he not dead," said his mother. "I really don't know if this killing can go on. I hope it ends. I do hope so."

A policeman nearby in the hospital stood waiting for treatment, his arm full of shotgun pellets received in a shootout with gunment trying to steal a ballot box. Those gunmen were driven back, but elsewhere in the city at least three boxes reportedly were stolen successfully. Late in the afternoon a polling station in the barricaded street near the hospital was the scene for the second time in a day of a major gunfight. Seaga himself was on the scene to observe and direct his security guards, but escaped unhurt.

The passions run so high in Jamaica because of the nation's terrible economic condition after seven years of negative growth under Manley's regime. eWith unemployment well above 35 percent, the youths of Kingston have little left but their faith in their leades and plenty of time to fight for them.

Manley had sought to place the blame for the nation's condition on powers beyond his control and on "reactionaries" such as Seaga and his backers who Manley said sabotaged the nation's economy.

Preliminary reports indicate some of Manley's key Cabinet ministers, including Finance Minister Hugh Small, have lost their seats in Parliament altogether.

Many Jamaicans are hoping that such a decisive election victory will bring peace to this beautiful island. But for the residents of Trenchtown there still appears to be little to look forward to in the near future.

"It was pure gunshots from here to ther polling station," said one woman there. "It will be sleepless nights for us now. All tonight we won't sleep at all."