South African Prime Minister Pieter W. Botha said today that U.S. military personnel ordered out last week for alleged spying had failed to heed a warning two months ago to cease photographing "sensitive military installations" from an embassy-owned plane.

In a sharp new attack in Parliament on the U.S. government, Botha also listed a series of alleged deviations by American military personnel from their assigned functions that had led the South Africans to suspect they were engaged in "espionage."

The Embassy refused to comment on the new allegations.

[State Department spokesman Hoddling Carter would not comment on Botha's latest charges but said, "We strongly hope and urge that if there are concerns they be submitted in normal diplomatic channels and be discussed in that way."]

In the absence of a U.S. version of the intelligence-gathering dispute, Botha's new allegations cast the United States in an even more questionable light for South African public opinion - which had united solidly behind the government's highly publicized expulsion of the three military attaches last week.

At the same time, however, it appears that the "spy plane" furor, which has brought relations to their lowest point yet, is intended more to discredit the Carter administration than to make an enemy of the United States.

"I wouldn't like to lose the good will of the United States of America, but surely friends don't spy on each other." Botha said tonight in a television interview. "But as long as that spirit is coming from the regime at present in power in the United States . . . our friendship is in jeopardy."

Botha added, "I hope that the American people themselves will see to it that our proper relations are restored."

Despite Botha's reopening of the spying incident today, foreign affairs officials said yesterday that the government was not contemplating any further action against U.S. personnel here.

"The military attache concerned was visited by a senior South African offical and warned that his behavior was not what was expected of a friendly country," Botha told Parliament. The attache did not heed the warning, given Feb. 9, Botha said.

The prime minister, who is also defense minister, charged that the U.S. military personnel, who must leave the country by Friday, had engaged in other offending activities, including illegally gathering information after it had been refused them through normal channels, gaining entrance to restricted areas "on false pretenses," questioning South African forces "on restricted information," and "making unathorized contact with certain military officials in conflict with the rules." Botha did not elaborate on what rules he meant.

Botha said the camera fitted to U.S. Ambassador William Edmondson's plane had photographed "areas involved in attacks against South Africa."

This could only mean the northern border area of the pre-toria-administered territory of namibia (Southwest Africa) where South Africa is engaged in a guerrilla war with a Soviet-backed black nationalist group, the Southwest Africa People's Organization (SWAPO).

Botha said such photographs could help the "communist guerillas" in their war effort and he then declared that if such assistance was given SWAPO by U.S. military personnel. "It was an act of war against South Africa."

Once again, Botha demanded that the U.S. government explain "why it had spied on a friendly country" and added that until this was done, South Africa could not be blamed "if it looked upon certain people with the gravest suspicion."

"South Africa cannot compete with the superpowers. But South Africa has the same self-respect as the superpowers and we will stand by our rights and not be pushed about by them," Botha said. "South Africa is not the doormat of any superpower"

South Africa "could have acted much more strongly" than it did against continued photographing by the plane, he said. If the incident had happened in the United States, Soviet Union or France, "those countries would have taken for stronger action," he said.

Botha said South Africa was still committed to the Western proposals for a peaceful transition to independdence in the territory of Namibia although "we have lost confidence in the west."

But in Nambia, a South Africian-allied political party has begun to organize an interim government with legislative powers in direct violation of the western proposals. This has heightened suspicions that South Africa is leading the territory toward an independence without the U.N. supervision forseen in the Western plan.