The Allied command in West Berlin today banned persons posing a threat to the city's population, giving local police authority to bar suspected terrorists from entering the city, an official Allied statement said.

The move was seen as a response to the bombing of a West Berlin discotheque last week, which killed a U.S. soldier and a Turkish woman and injured 204 others, including 64 Americans.

The measures were agreed on today by officials of the United States, France and Britain, the three powers that have responsibility for the security of West Berlin under a post-World War II agreement and are the supreme legal authority in the western sector of the divided city.

The step is a move against "international terrorism," a Berlin-based diplomat said. It orders West Berlin police to "remove from the western sector persons identified as posing a threat to the population of the city," effective immediately.

It now is relatively easy for noncommunists to travel from East Berlin to West Berlin by subway, and the move could have the practical effect of tightening passage from East Berlin if police begin checking documents at stations near the border.

But allied officials refused to say whether Libyans are the particular target of the new antiterrorist action. U.S. officials, including Ambassador to West Germany Richard Burt, have alleged that Libyans were involved in the bomb attack.

"Various indications" point to the involvement of representatives from the Libyan People's Bureau in East Berlin, West German government spokesman Friedhelm Ost said here Wednesday.

Yesterday, West German Chancellor Helmut Kohl said that there were "a whole number of indications that the bombing also had a Libyan background."

Following the bombing, the United States launched a week-long campaign for allied approval to ban Libyan diplomats stationed in East Berlin from crossing into the western sector of the city, but French officials reportedly resisted singling out Libya on the grounds that the evidence did not justify such a step.

Today's action appeared to be a compromise.

It will allow local police to carry out identification checks on subways and buses throughout the city and expel anyone suspected of being a threat, a western diplomat in Bonn said. It represents "considerable expansion of West Berlin police authority to root out troublemakers or would-be troublemakers," he said.

But allied officials reached in West Berlin declined to say whether the action will allow West Berlin police to move against East Berlin-based Libyan diplomats when they enter the western sector of the city.

The Libyan mission in Bonn, the West German capital, rejected the West German charges in a statement released today and called on the West German chancellor to prove the allegations.

Diplomatic sources here have reported that coded radio messages between Tripoli and the Libyan mission in East Berlin form the basis of U.S. assertions that Libya was behind the attack.

In Tripoli, Col. Muammar Qaddafi, claiming the United States has targeted Libyan Army camps for attack, said Saturday night that he turned over the installations to foreign companies to house their employes, including U.S. citizens.

"We have closed all the military camps specified by the United States to be attacked. We have handed them over to foreign companies to repair and maintain and to be used as residences for employes of the oil fields and petrochemical companies," a spokesman for Qaddafi said according to United Press International.

"All the foreign workers from the oil fields will live in these camps permanently . . . . The number of Americans in these camps comes to some 1,000," the spokesman said.

"This means we are ready for war if we are attacked," he said. "We will not stand still in the face of an American aggression. We have moved our (Army) camps to unknown locations."

Libya also said it might ask Warsaw Pact forces for help against the "aggressive alliance" of the United States and Israel in the event of a U.S. retaliation for alleged Libyan involvement in terrorism.

The warning on official Libyan radio came hours after Qaddafi, in an interview with UPI, threatened to attack "all southern European cities" if the United States attacks Libya.

Libyan state radio said that NATO Secretary General Lord Carrington had expressed support for "the arrogant, aggressive U.S. measures" against Libya, The Associated Press reported.

A spokesman for the North Atlantic Treaty Organization, Robin Stafford, said at its headquarters in Brussels that Carrington "has said nothing that could be construed as a NATO threat to Libya."

[Stafford said NATO has taken no official position on a possible U.S. military strike at Libya. Carrington has said that America's European allies probably would favor the United States "doing something" to retaliate if it was proved that Libya sponsored the bombings of the discotheque and a TWA jetliner over Athens on April 2.]

In Milan, Italian Prime Minister Bettino Craxi said his government would react with "great firmness" to threats by Libya against Italy or other Mediterranean countries. Craxi said he is to meet a U.S. envoy Monday and that he did not expect any U.S. military action before then. The Reagan administration has dispatched U.N. Ambassador Vernon Walters to consult with European allies.

The European Community scheduled a meeting in The Hague on Monday in response to Spanish and Italian requests to discuss the terrorism issue.

The U.N. Security Council held a four-hour closed session today to consider a request by Malta, which has friendly ties with Libya, for an immediate debate on the latest U.S.-Libyan dispute.

At a brief public session, Saviour F. Borg, Malta's deputy U.N. delegate, asked the 15-nation council "to consider and take appropriate and urgent action to stop the repeated threat of use of force, as well as the imminent resort to armed attack in the central Mediterranean."

Malta circulated a draft resolution tonight, which the council plans to consider Monday. It calls on the secretary general to "take immediate action with the parties concerned to ensure that only the peaceful means . . . are utilized to reconcile any differences between them."

Neither the Maltese delegate nor the resolution referred to the United States by name.