Countries with views generally closer to the United States and its major allies won election in the General Assembly today to four of the 15 seats on the Security Council, setting up a potential working majority on the most influential of U.N. bodies for the first time in years.

In one of two contested elections today, Thailand defeated Mongolia, a member of the Soviet Bloc, in an open contest for the Asian seat now held by Pakistan. The Thais reached the requisite two-thirds majority on the fourth ballot.

But the major swings for the West came in the uncontested elections of Trinidad and Tobago to replace Nicaragua and Australia to succeed Malta. In addition, Denmark was unopposed for the council seat now held by the Netherlands.

The fifth contest for a two-year term on the council, which begins Jan. 1, remained undecided today. After four ballots, Ethiopia was ahead of Somalia 83 to 72 for the African seat now held by Zimbabwe, in another contest between Soviet and U.S. allies. Another such contest four years ago, involving Cuba, went on for three months and more than 100 ballots before a backstage compromise was reached.

Even without the contested African vote, diplomats noted, the United States and its allies will be able to build a coalition on a number of issues that could command the nine votes needed to adopt any substantive resolution. Such a grouping would force the Soviet Union to cast a veto to block council actions, which are otherwise legally binding.

One year ago, the United States found it difficult to gather nine votes for the resolution deploring the Soviet destruction of a Korean airliner. Come January, such a majority will be assured.

That coalition would be built around the three western permanent members of the council (Britain, France and the United States), the four nations elected today and Egypt and Peru, two of the five nonpermanent members whose terms have another year to go.

The other nonpermanent members of the Council are Burkina (formerly Upper Volta), India and the Ukraine. China, like the Soviet Union, is a permanent member with veto power.

U.S. Ambassador Jeane Kirkpatrick issued a statement tactfully noting the significance of the shift by welcoming "the renewed vigor of independent moderate forces within the Third World and elsewhere," as indicated by their "strong showing" in the elections.

However, western diplomats warned that on some issues -- Southern Africa, Central America and the Middle East -- a majority could still be built for resolutions that would provoke more of the U.S. vetoes that have abounded in recent years.