ONLY a few hours after police and security experts began their stakeout at the Libyan embassy in London last week:
* Voices inside the besieged embassy building were being heard through directional microphones.
* Telephoto television cameras were trained on the front door and all the windows.
* A highly secret machine that can keep track of people as they move around behind brick walls swung into operation, using human body warmth as the measurement factor.
Overnight, London's sedate St. James's Square had become an electronic village as official eavesdroppers and Scotland Yard's top visual surveillance experts brought out their most sophisticated hardware.
A Scotland Yard officer compared this operation to the fighting in the Falkland Islands two years ago. Then, modern weapons never before used in a real war were employed.
This time electronic gear, some of it supplied from the United States, was glimpsed by the public for the first time.
Early in the siege, police draped huge blue plastic curtains across the entrances to St. James's Square. Behind the curtains the electronic village began to expand.
The television viewing public gained glimpses of what was happening as enterprising cameramen climbed onto nearby buildings. They saw laser directional microphones being set up. Police trained them on windowpanes that vibrated when people behind them began talking. At one point telephone workmen drove through the blue curtain, dug a hole in the road, and began their mysterious task of peering at and joining up wires.
One evening a large military plane made passes over St. James's Square. The noise of the jet engines was used to drown out drilling and boring noises by police as they spiked the walls of the besieged building with microphones.
For days on end police helicopters hovered above St. James's Square, as TV cameras aboard kept track of movements on the roof of the Libyan Embassy.
London police had experience of three major building sieges before the Libyan Embassy crisis: a takeover by criminals of a West End spaghetti restaurant, a group of Irish Republican Army gunmen holding out in a block of flats, and the occupation of Iran's London embassy in 1980.
These events have enabled Scotland Yard to develop a ''siege kit,'' which was used to the full in St. James's Square. But in this case there was an additional problem.
In the earlier cases, hostages were released, and they were able to inform police about what had been happening inside the besieged premises.
This time, Scotland Yard had no hostage help. But officers were able to get hold of plans of the building dating back nearly 200 years and tried to work out the layout of the Libyan People's Bureau. The body-heat measuring device was used to try to count the number of people inside the embassy, but it is not known whether the attempt proved successful.
The nerve center of the electronic village was a large white van in which information about developments inside the embassy was collated and interpreted. From there it was immediately flashed to the Foreign Office, the Home Office, and 10 Downing Street so ministers and officials coordinating the siege could be kept fully informed.
And while their colleagues kept the embassy under constant surveillance and scrutiny, police marksmen in blue berets kept it in their sights around the clock. For their nighttime vigils, the police erected floodlights in some areas of St. James's Square. For shady corners nearer to the embassy, they used ''image intensifiers'' - devices enhancing the available light and enabling marksmen to get a sharp view of potential targets.
How much did the electronic village cost? During the crisis it was a question hardly anybody had begun to try to answer.
Scotland Yard officials speculated the final cost would run into millions of pounds, partly to pay for police and others involved in the stakeout, but, above all, for the extraordinary agglomeration of high-tech equipment used to keep visual and acoustical tabs on Libya's London mission during a period of high crisis.
In a similar incident Thursday, a small group of anti-Khomeini demonstrators took over the Iranian consulate in London after scuffling with Iranian consular officials and issuing a set of demands. Scores of British police sealed off the area and took up positions on roofs.
(UPI reports that after a fight that left tables and chairs broken and injured two of the intruders, pro-Khomeini consulate staff overpowered the protesters.
(Almost nine hours after the occupation started, the Iranian officials began turning over the protesters to police, taking them out the consulate door with their hands tied behind their backs.
(Consulate staff shouted ''Long live Khomeini'' and ''Down with the US'' as ambulances stood by to take away the injured.)