BEIJING (AP) _ Hundreds of foreigners rushed to Beijing's international airport today to board hastily arranged flights and evacuate the tense capital.

Airlines from Denmark, Japan, the Philippines, Switzerland and the United States dispatched jetliners to carry out citizens unnerved by the carnage and random shooting by troops roaming the city.

About 270 Americans left Beijing's Capital Airport aboard a special United Airlines flight for Shanghai, where another 130 were to board and then head to Tokyo.

''I was at the Beijing Hotel Monday watching people get shot all day and that was enough,'' said an American student from he Bejing Foreign Language Institute who watched troops, their rifles blazing, charge repeatedly at crowds of bystanders.

''After being at Tiananmen that night and watching them shooting and shooting and shooting, I reached my threshold for destruction,'' said the student, who was waiting for a Dragonair flight to Hong Kong before making his way back to New Jersey. He asked not to be identified.

A Continental Airlines jetliner that was turned away from Chinese airspace on a flight from Japan earlier today departed again for Beijing after receiving permission from Chinese authorities, an airline official said in Tokyo.

People's Liberation Army soldiers stormed thousands of pro-democracy protesters in Tiananmen Square over the weekend, killing hundreds in the most violent suppression of a popular movement in communist China's 40-year history.

On Wednesday, soldiers fired on a diplomatic compound, and the State Department in Washington ordered diplomatic dependents at the U.S. Embassy and all non-essential personnel to leave China. Officials also urged all other Americans to leave.

''We've taken an awful lot of moves to improve our security, and the biggest one was putting those people on that plane and pulling them out of town,'' U.S. Ambassador James Lilley told reporters at the airport.

''We're watching things very closely. We think there are enough signs of difficulties that we'd better take care of our people and get them out fast.'' Dozens of cars and buses plastered with the flags of Italy, Japan, Malaysia, Mexico, Sweden and the United States made their way along the picturesque, tree-lined route to the airport.

The Spanish ambassador's black Mercedes Benz pulled up to the terminal near the American ambassador's navy-blue Cadillac.

About 1,000 people crowded the dusty departure terminal amid tearful embraces and anxious passengers hoping to get a ticket out. The Bank of China office was jammed with people changing money, and the snack bar above the lobby was nearly full.

Five planes from Japan Airlines and All Nippon Airways, including two emergency JAL flights and one from ANA, had flown 1,170 passengers to Tokyo today, said Japanese Embassy spokesman Shigekazu Sato. Another ANA jet was to take a few hundred more Thursday night, he said.

''We were going to leave tomorrow, but the embassy and our company told us to get out as soon as possible,'' said Naomi Nishi, an interpreter for Japan's Seibu-Saison Group, which is setting up a joint venture furniture company.

All 30 of the firm's Japanese employees were leaving today, she said.

''I wanted to stay six weeks, but we have to leave after one week because it is getting very dangerous,'' said a 29-year-old Swiss tourist who was taking a Swissair plane sent to take the Swiss and Austrians to Zurich.

She and other students spent two nights at the Swiss Embassy out of fear of soldiers who constantly cruise Beijing streets, pointing their rifles at people and shooting occasionally.

''We slept in the embassy garden,'' said the woman, who spoke on condition of anonymity. ''It was very comfortable. They have a roof, and thick blankets to sleep on.''

Karin Denkmayr, an Austrian studying at the Beijing Academy of Drama, was taking the same flight.

''I don't want to leave but the Austrian government and Ministry of Foreign Affairs say I had better,'' she said. ''If it gets to a critical situation then we can't get out.''

The Philippine government sent a commercial airliner to fetch 300 Filipinos after bickering among several government agencies and the state-run Philippine Airlines.

Some Philippine Embassy dependents had to beg for seats aboard an earlier Singapore Airlines flight because the PAL jet was held up.