Libya's release of four Britons held for four months touched off an unseemly clash today between the archbishop of Canterbury and the office of Prime Minister Margaret Thatcher over who initiated the successful diplomacy.

At the same time, British officials said the expected return Thursday of the four Britons released yesterday could lead to some improvement in relations between the two countries.

The four were arrested in apparent reprisal for Britain's breaking of diplomatic relations and expulsion of Libyan diplomats in April after a London policewoman was killed by shots fired from inside the Libyan mission.

Their arrest came in May after an attack by Libyan rebels in Tripoli near the barracks headquarters of Libyan ruler Col. Muammar Qaddafi.

The release was negotiated over the past several months by Terry Waite, a senior deputy in the Church of England to the church's spirtual leader, Archbishop Robert Runcie. Waite, a bearded, 6-foot-8 deputy for overseas affairs, is an articulate international troubleshooter for the church who has won praise for this and other missions.

Church sources said they read with some annoyance stories in today's newspapers about how Waite's mission was undertaken at the request of the prime minister. The stories said Thatcher, after having met with the families of the Britons on Oct. 17, wrote Runcie at their suggestion proposing that Waite go to Tripoli to plead for the release.

Downing Street did not actually issue such a version but it was to be "made available" to any reporter who asked and a copy was given to the church.

Today, the church said, "The archbishop of Canterbury's first letter to Col. Qaddafi concerning the four British detainees was written on Aug. 1, 1984. From that day onwards, active negotiations were underway to arrange for Mr. Waite to visit Libya." The church said Thatcher's letter only "encouraged an initiative that was already underway."

The Waite mission was actually instigated by the wife of detainee Alan Russell, who wrote to Runcie last July, pointing out that her husband was organist in the Anglican church in Tripoli.

Throughout the conflict, Thatcher's government has refused to release four Libyan students who are accused of taking part in bombings in Manchester between November 1983 and March 1984. The trial of the four students began yesterday.

The Libyan government has demanded that Britain "work for the release of Libyan prisoners in Britain" but apparently did not make freeing the four Britons contingent on the students' release.

The Libyans apparently did hold up release of the four into Waite's custody for a day because the British government unveiled a memorial to the slain policewoman last Friday, just as the release process in Tripoli was at a crucial stage. The government said the ceremonies had been planned months in advance, but some of the families of the detained Britons were sharply critical of the government's timing.

Foreign Office sources said that once the four men -- two teachers, an oil company worker and a telecommunications engineer -- are safely back in Britain, there could be a relaxation of tensions with Libya.

They said the most likely first step would be to make it easier for some Libyans once more to enter Britain. This could involve issuance of visas in Tripoli for entry to Britain on humanitarian or medical grounds. Since the breaking of relations, Libyans seeking to enter Britain have had to go to third countries for the few visas issued.

This step is said to have been discussed with Libyan contacts during the lengthy efforts to get the Britons released, and sources said it was the only example of possible diplomatic moves to improve relations that was held out to Tripoli.

The sources said Britain was prepared to maintain its low-key diplomatic presence in Tripoli. There are now about 5,000 Britons left in Libya, compared to 8,000 a year ago, and British interests are handled by a consular official working out of the Italian Embassy.

The British have also offered to help Saudi Arabia, which represents Libyan interests in London, find larger premises for the Libyan interests section, but only provided that the Saudis maintain clear control and outnumber the Libyans. The sources said this offer has been known to Tripoli for some time.

One of the four released prisoners, Robin Plummer, 33, an engineer for British Telecom, told a news conference in Tripoli today about "a typical, thoroughly boring day" in captivity.

"About 9 a.m., the guard would come to the door and wake us up. I used to scream for two minutes when I remembered where I was. Then it was a question of breakfast, and Monopoly until lunch, and after lunch it was cards, or reading, or sleeping until dinner, and then after dinner it was cards until it was time to go to bed. We got into a routine simply so that we would have something, no matter how small, to look forward to."