LONDON (AP) _ Libya freed four imprisoned Britons on Tuesday in a suspenseful televised announcement watched by their families. Prime Minister Margaret Thatcher hailed the prisoners' release as a ''welcome development'' and urged Libyan authorities to speed their return.

The Church of England, which mediated the release, said the men would probably return to Britain Thursday night after getting exit visas and other documents required by Libyan authorities to leave the country.

The four Britons were jailed for nine months, allegedly for offenses ranging from smuggling state secrets and anti-Libyan writings to committing a minor traffic infraction. One was convicted and two were never charged.

Suspense began building last weekend when Tripoli indicated it was ready to release the men on Monday. Terry Waite, special envoy of Archbishop of Canterbury Robert Runcie, was called to the ornate People's Palace in Tripoli to take custody of the men Monday morning.

But when Waite got there, he was told the release had been postponed for at least 24 hours. Tuesday morning he was summoned back for the annoucement of the prisoners' release.

Libyan authorities arrested the four soon after Britain broke diplomatic ties with the North African nation. The rupture followed the killing of a policewoman outside the Libyan Embassy in London in April 1984 by shots fired from inside at demonstrating Libyan exiles.

Libya indicated that it delayed the men's release out of indignation at Mrs. Thatcher for unveiling a monument last Friday to the slain policewoman, Yvonne Fletcher.

In Tuesday's announcement in Tripoli, carried via satellite by the British Broadcast Corp. and British radio stations, a Libyan official said the men were freed as a gesture to the Anglican church and the British people, but said an overwhelming majority of the legislative bodies set up by leader Moammar Khadafy had favored attaching conditions.

Sitting beneath a photograph of Khadafy, government spokesman Mohammed Alhijazi read a statement that was watched by the prisoners' families in Britain.

Only 272 of the Basic People's Congresses had favored freeing the men unconditionally, he said, while 1,752 had demanded terms such as the release of Libyans held in Britain, an end to ''anti-Libyan propaganda'' in the British news media and withdrawal of London's support for ''stray dogs'' - a Libyan designation for Khadafy's enemies.

Alhijazi's statement was prolonged by the translation from Arabic to English, and only at the end did the spokesman end the suspense.

Despite the demand to set conditions, Alhijazi said, ''We can say that the decision is to release the British prisoners. Henceforward, they are free either to stay here or to leave for any other country.''

While the Archbishop of Canterbury's envoy, Terry Waite, was expressing thanks, the prisoners were escorted into the room.

Speaking on the television hookup with Tripoli, teacher Michael Berdinner, 52, said: ''I feel absolutely stunned, but also very relieved.''

Engineer Robin Plummer, 33, said detention was ''pretty tough'' but said the men kept their minds occupied with games and puzzles.

Oil engineer Malcolm Anderson, 27, said: ''We've been looked after all right. I feel a lot more relaxed now. I've had assurances from Mohammed (Alhijazi) here that everything's going to be okay.''

Teacher Alan Russell, 49, addressed his reaction to his wife Carol in England.

''Hello darling, it looks like we're there now. Wait till I get home, though,'' he said.

Interviewed after the broadcast, Mrs. Russell complained that the British government had been unhelpful in securing the prisoners' release. Until the Church of England's envoy began shuttling between London and Tripoli, she said, ''We couldn't get anyone to help the men.''

Russell was sentenced to three months in jail after being convicted of possessing state secrets and communicating with the British Broadcasting Corp.

Anderson was picked up at Tripoli Airport as he was leaving the country carrying 15 letters for friends. He was charged with attempting to smuggle out state secrets and anti-Libyan writings.

Plummer, arrested for a minor driving offense, and Berdinner, whose offense was never disclosed, were not charged.