Soviet leader Mikhail Gorbachev has said his government is prepared to renounce formally the targeting or use of nuclear weapons against Britain or any other country that removes all nuclear armaments and foreign nuclear bases from its own soil.

In a lengthy letter to a socialist local government leader here, Gorbachev noted that "the comparatively small British Isles" were being "stuffed" with nuclear weapons. Their presence, he warned, "does not consolidate anybody's security."

The offer to renounce nuclear use against specific countries was part of an ongoing Soviet effort to persuade western governments that they can best assure their own security by eschewing nuclear weapons and distancing themselves from U.S. nuclear policy.

Britain maintains its own independent nuclear deterrent as well as providing sites for cruise missiles at U.S. bases here. In a brief statement today, Prime Minister Margaret Thatcher's government dismissed Gorbachev's offer as "nothing new."

"Unilateral nuclear disarmament would leave the United Kingdom vulnerable to nuclear blackmail, while the Soviet Union retained nuclear weapons," the statement said. "Greater security and stability require real and substantial reductions in the arsenals of the superpowers and not declaratory gestures of this type."

But the Soviet proposal is likely to strike a more responsive chord in countries such as Greece, a NATO member, and New Zealand, where it is in line with widespread public opinion and government inclination.

Any country is eligible for the offer, Gorbachev said, "no matter if they are members of military alliances or not. There is only one condition for us: If this or that country refuses to acquire nuclear weapons and does not have them on its territory, it receives from us firm and effective guarantees.

"For example, if Britain fully rejected nuclear weapons and dismantled foreign nuclear bases on its territory, the U.S.S.R. would guarantee that the Soviet nuclear weapons will be neither trained on the British territory, nor used against it. These guarantees could be legalized through concluding an official agreement that would take into account all the corresponding military aspects."

The text of Gorbachev's letter, dated Dec. 30, was released today by the Soviet Embassy here, and by the office of its addressee, Ken Livingstone, the leader of the Greater London Council, the municipal governing body for London. It was written in response to a Dec. 4 letter from Livingstone in which he informed Gorbachev that London had declared itself an independent "nuclear free zone" and asked for a Soviet pledge that nuclear weapons would not be used against it.

A spokesman for the council said that an identical letter had been sent by Livingstone to President Reagan, but that no reply has yet been received. The council, along with six other big city authorities controlled by the Labor Party, will be abolished in March under a bill backed by the Conservative Party. The authorities' functions, which include overseeing city services, will be handed over to smaller borough authorities.

The "nuclear free" declaration, first made by the London Council in July 1981, rejects the use of the London area for the manufacture or siting of nuclear weapons, and says that no nuclear materials for military use can be transported through the city.

Similar declarations -- none of which has any legal force against national government policy -- have been adopted by about 170 local government bodies in Britain, virtually all of them, like the London council, under the control of the opposition Labor Party. Labor defense policy calls for the unilateral dismantling of Britain's independent Polaris submarine nuclear force and the removal of U.S. nuclear missiles based here.

A spokesman for Livingstone called Gorbachev's letter "a positive step" and said "we're waiting to see if Reagan can match it."

The bulk of Gorbachev's letter, which covered three full pages in a Soviet-supplied translation, congratulated the London Council on its efforts "to make a contribution to the common efforts of the peoples aimed at removing the nuclear threat and reviving an atmosphere of trust and mutual understanding in relations among states."

It repeated recent Soviet offers for an immediate freeze on all new nuclear deployments and a joint 50 percent cut in existing offensive nuclear weapons with the United States at arms control talks in Geneva.

"Naturally, progress at the Geneva talks is only possible if space strike armaments are completely prohibited, in other words, if the 'Star Wars' program is renounced, as its implementation could lead to strategic chaos," Gorbachev said in reference to the Reagan administration's Strategic Defense Initiative.

The administration, backed by NATO, maintains that its research into a space-based strategic defense system is necessary to match similar Soviet research efforts. A number of NATO countries, however, including Britain, have asked for a U.S. guarantee that no such system will be deployed without allied consultation and negotiation with the Soviets.

The Soviets have tried to use their propaganda, with little success, to build on what they perceive as grounds for division in NATO opinion and to persuade U.S. allies that the SDI program should be scrapped.

Gorbachev recalled that the Soviet Union had pledged no first use of nuclear weapons and that it had introduced a six-month moratorium on nuclear tests. The moratorium expired at the end of 1985.

He said his government was "prepared again to sit down at the negotiating table in the immediate future to find, together with representatives of the United States and Britain, a mutually acceptable solution" to the testing problem.

Although both the Soviet Union and the United States currently are pledged to engage only in underground testing, the Reagan administration has rejected the moratorium offer.