The Iranian government's diplomatic corps unceremoniously vacated the Iranian Embassy and left the United States last night, complying with President Carter's midnight deadline for its departure.

A delegation of 51 Iranians, comprising 14 of the 15 Washington-based embassy personnel and their relatives, left Dulles Airport at 10:18 p.m. on a British Airways flight to London. The 20 other U.S. based Iranian diplomats stationed at consulates in New York, Chicago, Houston and San Francisco also left the country before midnight on other flights.

The Iranians' departure capped a day of tense developments, including unsuccessful attempts by more than a half dozen of the diplomats to appeal the president's order for their expulsion, which was part of a four-point program of sanctions against Iran for continuing to hold an estimated 50 Americans hostage in the U.S. Embassy in Tehran.

One of the diplomats assigned to the embassy here did miss last night's flight, but a State Department spokesman said the official, financial affairs director Abdol-Azim Biabani, was expected to leave the United States today.

Biabani was admitted to Suburban Hospital in Bethesda at 4:30 p.m. yesterday, complaining of chest pains.

The State Department official said that Biabani "has no plans to seek aslyum here, and if he did, none would be granted," just as efforts by others to stay behind were rejected.

After the diplomats left the embassy at 3005 Massachusetts Ave. NW, federal agents and District of Columbia police searched the building to make certain that no Iranians were left behind and because of reports that there might be a substantial arsenal of weapons there.

The search was completed shortly before 1 a.m. today with no hidden Iranians or weapons found. One senior D.C. police official said the search teams had seen nothing unusual in the building, and no evidence of purposeful destruction of equipment or files. Minutes later, police barricades set up Monday on Massachusetts Avenue north and south of the embassy were removed and traffic was allowed to flow freely again.

The building, which was the secne of some of Embassy Row's most lavish parties during the reign of the shah, will be turned over to a third-party nation, according to diplomatic custom.

The last time the United States took the initiative and severed diplomatic relations with a country was in 1961, when ties with Cuba were cut after Fidel Castro installed a Communist regime in Havana.

State Department sources said that one of the Iranian diplomats who asked to be allowed to remain behind pleaded that he needed to stay because his wife is undergoing treatment for cancer here. State Department officials are reported to have determined that her treatment could be continued in Tehran or another city abroad.

In other cases the last-minute pleas involved possible hardship on children of Iranian officials because schooling would be interrupted suddenly. These also were rejected, the sources said.

"A lot of these diplomats have been in the United States for years and years," said Michael Maggie, a local lawyer who made unsuccessful appeals to the State Department in behalf of some of the Iranians. "They have homes, automobiles, debts. What they did was they spent the day executing powers of attorney so that their friends can dispose of their property."

Maggio, who was in the embassy much of yesterday, said the atmosphere inside was calm, with diplomats and American workers packing belongings and saying farewells.

At 7:12 p.m., one embassy employe lowered the green, white and red-striped Iranian flag from the pole in front of the embassy building while other employes carried belongings, including a greater-than-life-size photograph of the Ayatollah Khomeini, onto the buses. (A Metro spokesman said the bus company demanded the $220 payment in cash, in advance. "It's not our usual policy, but we didn't want to take any chances," he said.)

The procession to the airport began at 7:40 p.m. Because most of the departing officials and their families went to Dulles in automobiles, only six adults and one child rode in the two buses, which also carried luggage and packages.

Flanked by unmarked cars bearing flashing lights and plainclothed Secret Service and FBI agents, the caravan moved up Massachusetts Avenue toward Wisconsin Avenue, passing a row of trees from which yellow ribbons fluttered to show support for the American Hostages.

Just beyond the barricade at 34th Street, the diplomats encountered the first of several anti-Iranian protests. Lawrence Vallario, a retired businessman who lives on Capitol Hill, said he had been standing there for six hours for the chance to wave an American flag and a sign at the Iranians.As they passed, he booed and waved the sign, which said. "Regards to the Ayatollah Satani" and "Take your sympathizers with you."

At the intersection of Massachusetts and Wisconsin avenues, one of the buses broke down, delaying the trip for a few minutes. While the baggage and passengers were transferred to another bus, the bells of nearby Washington Cathedral pealed.

The procession arrived at Dulles at 8:28 p.m., where American flags outside the terminal, both on staffs and in the hands of demonstrators, greeted the Iranians.

Also on hand were 30 to 40 Iranian sympathizers, who chanted "Long live Khomeini" and "God is great" in Farsi as Ali Asghar Agah, the Iranian minister-counselor and charge d'affaires, stepped into the light rain.

Acknowledging their chants and a picture of Khomeini hoisted in the air, Ali Agah smiled broadly and put his hand over his heart.

"Brothers and sisters," he said, addressing the gathering, "I am happy you are staying behind. I am sure you will be able to make the American people understand the justice of our revolution . . . Try to preserve your human dignity, which is a gift of God, and one no one is able to take away."

With that, Ali Agah and the other diplomats entered the huge terminal and headed for the British Airways check-in counter.

The rival demonstrators kept their distance, although two women engaged in a shouting match that culminated with one spitting on the ground and yelling, "Go back home and talk about freedom."

Randy Britt, an electrician from Sterling, who was wearing a T-shirt with a picture of Khomeini and the words, "Wanted: dead or alive" with the word alive crossed off, said he came to the airport "to get rid of the Iranians." His five-year-old twins waved American flags "to show their patriotism," Britt said adding that he was disappointed that "more people didn't show up."

Stuart Fleagle, 17, of Sterling park, who also wore a Khomeini T-shirt, said, "We should have done this five months ago."

Mike Garcia, 18, clutching an American flag, said he "just wanted to see these people out of our country."

Garcia got his wish about an hour later, when 51 Iranians boarded British Airways Flight 190 for the six-hour, nonstop flight to London. The Iranians had purchased $430, one-way "club class" tickets, which an airline official said was "in between first-class and tourist."

The flight was delayed just over an hour because of the late arrival and the large amount of luggage of the Iranians. The flight's other 259 passengers entered Dulles' mobile lounges at 8:55 p.m. for the ride out to the 430-passenger Boeing 747.

Before the Metrobuses departed for the airport, there was little activity outside the embassy yesterday.

About midafternoon, four hook-and-ladder fire trucks and a fire-rescue ambulance joined the fleet of police vehicles that had been posted along Embassy Row since Monday night.

Washington Police Department spokesman Joseph Gentile said the fire trucks were sent to the scene "in case of a fire in the embassy."

Most of the day law enforcement officers -- city police, FBI, Secret Service -- chatted quietly with each other and members of the press, and munched sandwiches and sipped coffee.

Occasionaly, a flock of Metro scooter police bounced along the ridges of woods up the hill from the embassy, once in response to a report that someone was walking through the woods toward the embassy.

Employes of other embassies in the area that had been cordoned off were permitted to pass through the blockades after showing identification.

Although there was little traffic in and out of the embassy before the buses were loaded, State Department officers who were waiting on the street got a report that someone inside wanted to deliver a diplomatic note to them.

"Don't accept it," said one State Department officer to a colleague. A few minutes later, one of them drove down to the embassy, and upon his return said, "Now they say they can't find the note."

Police checkpoints were set up at 34th Street on the north end of the cleared portion of Massachusetts Avenue and at Waterside Drive at the south end.