The Carter administration yesterday announced its willingness to sell counterinsurgency weaponry to Morocco's embattled King Hassan in an effort to encourage negotiations with guerrillas he is fighting for control of the mineral-rich Western Sahara.

A high State Department official said the government had agreed to meet the king's request for OV10 Bronco armed reconnaissance planes and Cobra helicopter gunships to help a longtime ally fend off intensifying attacks on Moroccan territory by Algerian-backed Polisario Front guerrillas, who are fighting to turn the disputed Western Sahara into an independent Arab state.

The State Department official said the decision to sell weapons to Morocco, which was a major shift in Carter administration policy, would be linked to achieving a negotiated settlement of the dispute. It was not immediately clear, however, how this linkage could be effected.

The announcement immediately ran into opposition on Capitol Hill Rep. Stephen J. Solarz (D-N.Y.), chairman of the House subcommittee on Africa, issued a statement castigating the decision as "compatible with neither our principles nor our interests."

The statement also warned that the arms sales "will encourage intransigence rather than flexibility" by King Hassan and "will prolong the war rather than shorten it."

Solarz had earlier writen to President Carter after a fact-finding tour of the northwest African region, advising him to maintain the existing U.S. policy of not selling Morocco weapons especially suited for use in the desert war.

Solarz predicted that the administration would face a tough fight in Congress to win the required approval of the sales.

The issue of selling the weapons to Morocco, and thereby involving the United States in the dispute, also has been a divisive one within the administration.

A high-level Policy Review Committee meeting last week was unable to agree on a single policy to recommend to President Carter, and each of several government bodies parricipating presented its own option paper to the president for a decision.

His decision apparently reflected a desire to demonstrate that the United States will stand by its friends abroad despite reverses in that policy regarding Iran. Saudi Arabia has been encouraging Washington to help King Hassan in his fight against the Polisario guerrillas and has indicated that it will finance the arms purchases.

Administration official indicated that the government would was willing to supply about six of the OV10 Broncos, an unspecified number of Cobra helicopters equipped with advanced TOW anti-tank missiles and other equipment such as armored personnel carriers and trucks.

The State Department official said Washington would "have to provide Morocco with more than token equipment" to strengthen King Hassan's hand enough to promote a negotiated settlement. The official added that it was up to the United States to see that the king did not use the weapons to pursue "a military solution," which U.S. intelligence reports have said would be difficult, if not impossible, for King Hassan to impose.

The administration also indicated that the weaponry it proposes to sell Morocco would not be sufficient to turen the tide militarily in favor of Morocco, even if the Moroccan army were better organized to fight the desert guerrilla war.

"We feel Morocco now has a self-defense problem because of numerous attacks from the Sahara into its territory," the State Department official said.

He said a 1960 agreement with Morocco limiting the use of U.S. weaponry to internal defense would remain in force, but indicated later that the administration would relax its interpretation of the agreement to allow Morocco to use the new arms "in parts of the Sahara."

The official said details governing Morocco's use of the weapons remain to be worked out. But he said the United States did not expect Morocco to carry its fight to Algerian territory, as some hardline Moroccan military men have suggested in advocating "hot pursuit" to clean out Polisario strongholds across the Algerian border.

The official also said the U.S. decision did not mean that the administration was recognizing Morocco's claim to the Western Sahara.

Despite the sales, the U.S. official said, the administration does not intend to become a party to the negotiations that it hopes will ensue to solve the Western Saharan conflict.

So far King Hassan has expressed a willingness to negotiate with Algeria on the issue, but not with the Polisario guerrillas. The States Department official said the administration would contact the king shortly, but declined to say whether the United States would encourage him to deal directly with the Polisario, which is also supported by Lybia.

At stake in the conflict is a sparsely populated stretch of rock and sand that is believed to contain valuable deposits of uranium and oil-shale as well as phosphates. The Polisario Front claims to represent the estimated 80,000 inhabitants of the Western Sahara, which was ceded to Morocco and Mauritania by spain in 1975. Mauritania renounced its claim to the territory in August because the war was crippling its economy.

In his statement, Solarz acknowledged that "Morocco has been our friend," but added that "friendship does not obligate us to support a war that can't be won a cause that is not just.

"While the administration's newly announced policy may please a few nations that would like to see Morocco prevail militarily, it will alienate many more countries that believe the people of the Western Sahara should be given the right to determine their own future," the statement said.

Salarz warned that instead of strengtheining King Hassan, the arms sales may eventually undermine him encouraging him to "continue waging an unwinnable war and diverting resources . . . that could best be used to solve real social and economic problems."