CAPE TOWN, South Africa (AP) _ A three-way peace treaty was signed Friday by South Africa and two feuding black homelands.

South Africa's white-led government had mediated the treaty to end the hostilities between Ciskei and Transkei, both impoverished homelands of the Xhosa tribe bordering the Indian Ocean. Only South Africa, which created the black homelands, considers them as independent states.

Signing the treaty were South African President P.W. Botha, President Lennox Sebe of Ciskei and Prime Minister George Matanzima of Transkei. The ceremony took place at Botha's official residence in Cape Town.

Last year, Sebe blamed Transkei for staging a prison break that freed Sebe's brother, Charles, who had been Ciskei's military and police chief before being jailed for an alleged coup plot in 1983.

In February, Ciskei blamed Transkei for an unsuccessful attack on Lennox Sebe's official residence and said it was an attempt to force a merger of the two homelands. One of the attackers was killed and two captured.

A few days before the attack, Ciskei had announced that all Transkeians in Ciskei would have to leave by Aug. 31.

Under the treaty, the three signatories agree not to use their territories or those of other countries for planning, inciting or carrying out acts of aggression against each ohter.

It provides for a three-man commission to resolve any disputes btween the territories that might endanger regional security.

Transkei and Ciskei are about 50 miles apart on the coast and as little as 15 miles apart farther inland.

Matanzima said after the ceremony, ''We shall all wait and see whether actions speak louder than words,'' he said.

Matanzima insists he remains in control of Transkei following widespread reports of discontent in his army. More than 20 white commandos who served as military advisers in Transkei were expelled last week, reportedly because their presence was opposed by black junior officers.