In a large trailer astride the border between South Africa and Botswana, South African Prime Minister Pieter W. Botha and Zambian President Kenneth Kaunda met today in only the third known session between the head of Africa's last bastion of white-minority rule and a major black African leader.

The two leaders, emerging after four hours of talks and a lunch, issued a statement saying they had engaged in a "frank exchange of views" on issues dividing blacks and whites in southern Africa, including independence for Namibia, the South African-controlled territory, and apartheid, South Africa's white-enforced racial segregation codes. The statement did not indicate that any agreement had been reached.

Later a Zambian aide, Milimo Punabantu, said that each leader had spoken "from the depths of his heart." Punabantu said the Zambians believed that the meeting had been "very constructive."

It was the first publicly announced session between a black African leader and a South African prime minister since August 1975, when Kaunda and Botha's predecessor, John Vorster, met in a railway carriage high above scenic Victoria Falls, midway between Zambia and what was then white-ruled Rhodesia.

That meeting is believed to have helped pave the way for the eventual resolution of Rhodesia's guerrilla war and the final transfer of power in 1980 to the black majority of what is now called Zimbabwe.

Vorster also went to Liberia in 1975 and met with then-president William Tolbert.

Today, Kaunda and Botha met in a trailer under a maroela tree in the wide-open spaces of the African bush. A baize-covered conference table straddled the border, with Botha sitting on the South African side, Kaunda on the Botswanan side.

The meticulous care over neutrality symbolized the delicateness of these talks. Kaunda has risked damaging his standing in the eyes of black Africa by meeting with Botha. Many black African leaders contend such sessions can only boost Botha's prestige and give him an aura of acceptability without achieving anything in return.

But Kaunda has always maintained a personal sense of mission about the white south, believing that reassurance and example can persuade the whites to relent.

His desire to meet with Botha appeared unexpectedly in an interview with a South African journalist last month.

South Africa, Kaunda said, was heading for a racial catastrophe and if it exploded, the entire subcontinent would burn. He said he would like to meet with Botha to try to persuade him to defuse the situation.

The suggestion came at a time when Botha was anxious to appear flexible, and Botha promptly agreed to the meeting.

Botha is under U.S. pressure to steer a racially moderate course that can help justify closer U.S. ties. At home he needs to woo liberal voters for support against growing right-wing opposition.

Kaunda had indicated earlier that he wanted to tell Botha he need not fear the South-West African People's Organization (SWAPO), the Namibian guerrilla movement, which he described as an African nationalist movement that posed no real threat to South Africa.

That view runs directly contrary to the position of leaders of South Africa's security forces, who see SWAPO as a surrogate of the Soviet Union. They contend that the guerrilla war in Namibia is part of a "total onslaught" directed from Moscow to destroy South Africa.

It is also understood that Kaunda pressed for the release of leaders of the outlawed African National Congress serving life sentences for trying to overthrow white rule.

Kaunda's contends that conflict in South Africa can be avoided only if the government negotiates with these leaders, whom he regards as the true representatives of the black population. Botha and his advisers, voice conviction that the congress is a dangerous communist surrogate.