Secretary of State Alexander M. Haig Jr. said yesterday that "time is running out" on the Middle East peace mission of special envoy Philip C. Habib but that the United States will continue its efforts to head off new military action.

Haig, speaking to reporters at the State Department after a meeting with South African Foreign Minister Roelof (Pik) Botha, said it is "still a long shot" that Habib will be able to bring about a negotiated solution to the Israeli-Syrian confrontation in Lebanon.

"This is an extremely delicate situation and replete with the most dangerous overtones," said Haig of the Lebanese tangle. He said that Israel and Syria have shown a degree of patience and understanding but that the substantive problem remains "extremely difficult."

The most ominous signs, according to administration officials, are the continues reinforcement of Israeli and Syrian forces in their border areas and the skirmishing of missiles and aircraft in the Bekaa Valley of Lebanon.

Syrian batteries reportedly fired surface-to-air missiles at Israeli jets Tuesday and reportedly shot down a pilotless Israeli reconaissance aircraft yesterday.

U.S. experts said Israel appeared to be drawing the fire of Syrian batteries in preparation for the promised air attack to destroy them unless Habib is successful in obtaining their voluntary removal.

Informed officials said Habib's prospects of success had improved somewhat since he undertook the peace mission last week, because of the passage of time with no outbreak of hostilities. But there was no indication of a breakthrough toward the "long shot" solution mentioned by Haig.

Regarding the disputed southern African territory of Namibia, the main subject of the meeting between Haig and the South African foreign minister, the chances for diplomatic movement appeared to be brighter.

Botha told reporters, with Haig at his side, that he sees "a very real possibility" of progress toward negotiating an end to South African control of Namibia "within the framework set out to me by the secretary of state of what the United States would be willing to do and not do."

Haig previously has made it clear that the administration is willing to take part in internationally sponsored negotiations to arrange an election for a future independent government in Namibia, provided that constitutional guarantees for the white minority are provided in advance. What he will not do, Haig said, is set a deadline for independence.

Botha endorsed the concept of advance guarantees for minorities, whether it is a constitution, another sort of document or a declaration guaranteeing rights. He said it would "allay fears and anxieties" among whites arising from statements of SWAPO, the predominant black group bidding for power in Namibia.

Botha's remarks expressed approval of the U.S. ideas is only the most general terms, but they appeared to indicate South African willingness to cooperate. This would be essential to any negotiated settlement of Namibia's status, according to administration officials.

Outside the White house late yesterday, about 500 persons protested the meetings with the South African foreign minister, who is scheduled to see President Reagan this morning.

The protestors carried placards and chanted slogans opposing U.S. dialogue with South Africa, calling for immediate independence for Namibia and urging U.S. recogition of SWAPO and of the government of Angola.

Rep. William H. Gray (D-Pa.) III told the crowd that the Congressional Black Caucus was introducing legislation banning U.S. private investments in South Africa.