The long, bloody guerrilla war in the remote southern African bush of Rhodesia was formally ended today by the signing of a comprehensive peace agreement in the glittering great hall of a magnificent Georgian mansion here.

An audience of international diplomats and British dignitaries headed by Prime Minister Margaret Thatcher stood and applauded after leaders of the warring sides in the seven-year-old conflict signed leather-bound copies of agreements reached during the 102-day Rhodesian peace conference here and smilingly shook hands.

"You have given the people of Rhodesia and of the neighboring countries new hope for the future," the conference chairman, British Foreign Secretary Lord Carrington, told Patriotic Front guerrilla leaders Joshua Nkomo and Robert Mugabe; the former Salisbury government's prime minister, Abel Muzorewa, and his deputy, Silas Mundawarara.

Thatcher called the peace agreement "the best possible Christmas present" and told the four men in separate meetings at 10 Downing St. earlier today that the world was relying on them to make it work.

Beginning at midnight tonight, the opposing forces are to be ordered by their commanders to begin to disengage from combat, and to fire only in self-defense. Armed Patriotic Front guerrillas are to stop infiltrating from bases in neighboring Zambia and Mozambique, and the Salisbury forces are to stop retaliatory cross-border raids that have killed several thousand people, in addition to the estimated 20,000 that have died inside Rhodesia since the racially oriented civil war began in 1972.

A week, from today, at midnight on Dec. 28, the British governor in Salisbury, Lord Soames, will declare a cease-fire. It is to be fully in force a week later on Jan. 4, with the Salisbury forces confined to 42 bases throughout Rhodesia, and the Patriotic Front guerrillas inside the country gathered at 16 scattered assembly places where they will be provided with housing, clothing and food.

Soames will then declare the beginning of a two-month election campaign to produce a black majority government for the first time since the country was occupied by white British settlers and ruled by the royally chartered British South Africa company during the 19th century. By mid-March, the British hope to grant legal independence to the country, to be called Zimbabwe, 14 years after its white-minority colonial government, led by Ian Smith, broke away from Britain.

Today in Salisbury, Soames lifted the ban on political activity by the Patriotic Front, which will allow Nkomo and Mugabe to return to Rhodesia to lead their political wings of the guerrilla movement into the election against both black and white parties that had participated in the short-lived biracial government headed by Muzorewa.

The first U.S. logistical forces arrived in Salisbury today to help carry out the massive airlift of about 60 flights being organized by Britain to bring in 1,200 Commonwealth troops and their equipment to monitor the cease-fire.

About 850 of these troops, mostly officers and senior enlisted men, are being supplied by Britain, with the rest contributed by Australia, New Zealand, Fiji and Kenya.

Three U.S. Air Force C141 Star-Lifters arrived today, and two flights of C5A Galaxies are expected over the weekend.

Forty-six U.S. Air Force personnel mainly based in West Germany arrived to assist in the operation. The U.S. personnel in Rhodesia are all to remain in Salisbury with plans calling for their role in the operation to end next Wednesday.

The timetable for all this had been set back a few days after Muzorewa and the white military commander of the Salisbury forces, Gen. Peter Walls, demanded and received in Salisbury a full explanation of the last-minute British offer of a 16th camp to house guerrillas. The proposal was made to persuade Nkomo and Mugabe to agree to the cease-fire this Monday.

But they and the other members of their delegation to the peace talks, except Ian Smith, finally flew here for today's ceremonial signing of the agreement at Lancaster House. The late Georgian mansion alongside St. James Palace on the Mall in the center of London is where Britain has held the Rhodesian peace conference since Sept. 10.

They gathered at noon with the Patriotic Front delegation, British officials, U.S. Ambassador Kingman Brewster, Commonwealth Secretary General Shridath Ramphal of Guyana, diplomats and newsmen in the 120-foot-long great hall of Lancaster House, its high walls and raised ceiling covered with gold brilliantly illuminated by television lights.

"The prize," Carrington told the opposing sides during the 15-minute signing ceremony, "is the end of war and enmity. It is the opportunity for all Rhodesians to devote their energies to peaceful activities."

But he warned that "it is essential to the success of the enterprise on which we are now engaged that all parties should realize that what have been signed at the conclusion of this conference are solemn and binding agreements.

"This will be a difficult period," he said. "Having committed themselves to campaign peacefully and to comply with the cease-fire agreement, no party or group could expect to take part in elections if it continued the war or systematically tried to break the cease-fire and to practice intimidation."

Even today, there were dark forebodings in statements outside Lancaster House here of the likely stridence of the coming election campaign. A Patriotic Front election victory, Walls warned, could result in "immediate civil war." Muzorewa contended that such an outcome would mean that "Zimbabwe would be finished economically [and] democratically."

Shortly afterwards, at a champagne reception under the golden chandeliers of Lancaster House, all parties to the agreement talked amiably together. Mugabe, considered the most fiery and uncompromising of the guerrilla leaders, said quietly, "We must make this work."