Britain will give the new nation of Zimbabwe $165 million over the next three years to help restructure its government and economy after the former British colony of Rhodesia gains its independence under black majority rule on Friday.

British Foreign Secretary Lord Carrington announced the aid package here today shortly before leaving for Salisbury to attend Friday's independence ceremonies.

British officials said the new Zimbabwe government of Prime Minister Robert Mugabe still must consult with the British on how most of the money will be spent. Some of it may be used to compensate white Rhodesian farmers whose land is to be distributed to rural black residents.

The Carter administration announced Monday that it would give Zimbabwe $15 million in economic aid, and the United Nations is providing $140 million to help black refugees resettle in Zimbabwe after years of exile in neighboring African countries.

British officials said more aid to Zimbabwe is expected from other countries, including those in the European Common Market and Scandinavia. It had been estimated that $1 billion or more may be needed to rebuild the war-torn country, although Carrington said today that Zimbabwe would soon be ready to "stand on its own two feet. Economically, it is perfectly viable."

At Mugabe's request, part of the money is earmarked for training blacks for positions in the police force, broadcasting system and civil and foreign services. Rhodesia's foreign service had almost ceased to exist during the past 14 years of illegal independence under white minority rule, and the other governmental institutions were largely run by whites.

Besides the $165 million in aid, Carrington said the British military will help train the new Zimbabwean Army, to be made up of the former Rhodesian military and black guerrilla forces. Integration of these forces began earlier this year after a peace agreement negotiated by Carrington ended a seven-year guerrilla war.

In Salisbury, Gen. Peter Walls, chief of the white-led Rhodesian forces in the war against the Patriotic Front guerrillas, today was named head of Zimbabwe's new military high command, Reuter reported.

Zimbabwe will become the 43rd member of the Commonwealth, the organization tying Britain to its former colonies. The Commonwealth countries and their secretariat in London were instrumental in launching and maintaining the British-run negotiations that produced peace and legal independence.

Carrrington also created controversy here today with the announcement that amnesty from prosecution would be granted to British firms that had violated the economic sanctions imposed on Rhodesia during the years of illegal white minority rule.

A government inquiry showed that British Petroleum, partly owned by the British government, and Shell, a British and Dutch company, allowed their oil to be sold to Rhodesia for nearly a decade after sanctions were imposed. Britain's attorney general, Sir Mitchael Havers, announced late last year that British Petroleum and Shell would not be prosecuted because of difficulty in proving criminal intent.

Carrington said today that a sweeping amnesty from prosecution for breaking the Rhodesian sanctions was consistent with the amnesty granted Rhodesians for political crimes connected with the colony's illegal break from Britain under former prime minister Ian Smith.

But Peter Shore, foreign affairs spokesman for the opposition Labor Party, argued in Parliament that while it was "absolutely right" to grant political amnesty in Rhodesia "to achieve the spirit of conciliation in that country," it was "a big mistake" to give amnesty to British firms who violated British sanctions laws.

Along with Carrington, the Zimbabwe independence ceremonies in Salisbury will be attended by Prince Charles, who will represent his mother, Queen Elizabeth II. Former ambassador Averill Harriman and former U.S. ambassador to the United Nations Andrew Young will represent President Carter.