An apparently incapacitated Menachem Begin resigned as Israel's prime minister today in a letter delivered to President Chaim Herzog by the Cabinet secretary, Dan Meridor.

Delivery of the letter to Herzog this afternoon brought the automatic resignation of the Begin government, which has been in power since 1977. It came more than two weeks after Begin announced his decision to resign and as concern mounted about his physical and emotional health. His condition today remained shrouded in mystery.

Under Israeli law, Herzog is required to consult with leaders of the political parties represented in the Knesset, Israel's parliament, and to ask one of them to try to form a new government. That is expected to be Foreign Minister Yitzhak Shamir, chosen by the Herut Party to succeed Begin as its leader. Earlier this week Shamir reached an agreement with other leaders of the present government coalition to remain in power under his leadership.

The consultations will not begin until Sunday, following the observance Saturday of Yom Kippur, the holiest day in the Jewish calendar. If Shamir's agreement with leaders of the coalition holds up, the process could be completed in a few days.

Behind-the-scenes political maneuvering is continuing, however, and could still present Shamir with problems.

Until a new government is installed by a vote of the Knesset, Begin will remain as prime minister of a "transition government" although there are now serious doubts about his ability to function in that capacity.

Despite earlier denials by Begin's aides, a well-placed source said before today's resignation that the 70-year-old prime minister has virtually stopped eating. The sources described Begin as "totally out of commission" and no longer functioning in any meaningful way as the head of the Israeli government.

Begin has not left his official residence on Balfour Street in more than a week. He did not attend Sunday's regular Cabinet meeting or synagogue services last week marking Rosh Hashanah, the Jewish new year.

The decision to send Meridor to Herzog's residence today appeared to confirm Begin's incapacitation. The outgoing prime minister is a fiercely proud man who has always placed great emphasis on protocol, and it was thought that only the most serious disability would prevent him from appearing personally before Herzog to make his resignation official.

The explanation offered by Begin's aides was that the prime minister has developed a skin rash that has kept him from shaving and that he did not want to be photographed in an unshaven appearance. This explanation, however, was widely discounted and followed assertions earlier this week by aides that Begin was suffering from a cold, the flu and finally "exhaustion," but that he was resting and hoped to regain his strength.

After the drama that followed Begin's surprise announcement Aug. 28 that he intended to resign, the formal act of stepping down was a low-key, anticlimactic affair for a once-active man who led an underground army fighting the British mandate authorities in Palestine.

Begin's brief letter to Herzog offered no explanation for the resignation. It said, "I hereby submit my resignation from the office of prime minister," and was signed, "Yours respectfully, and with all good wishes to you and your family for a happy new year, Menachem Begin."

In a statement he later read to reporters, Herzog, a member of the opposition Labor Alignment, paid tribute to Begin, who was Israel's sixth prime minister.

"I wish to take this occasion to express my deepest appreciation to Mr. Menachem Begin for his great efforts over the years on behalf of the people of Israel," he said. "This is not the occasion to detail his historic actions. They are indelibly inscribed in the pages of our national history."

Reuter reported that President Reagan also praised Menachem Begin, saying his "statesmanship and leadership have been a source of inspiration."

"Prime Minister Begin has shown the courage and determination to make the kind of difficult decisions for peace as demonstrated at Camp David, decisions which are so necessary to bring stability to this troubled region of the world," Reagan said.

Begin's Aug. 28 announcement was followed by frantic efforts by his political allies to get him to change his mind. But two days later he reaffirmed his decision, telling the Cabinet, "I cannot continue."

But he agreed to delay submitting his resignation to Herzog until his political allies had lined up a parliamentary majority behind a successor. The delay was designed to preserve the coalition and give Herzog no choice but to ask Shamir, the new leader of the Herut Party, to form the next government.

Monday night, Shamir announced he had reached an agreement to preserve the coalition. When Begin still failed to go to Herzog's home the criticism, public confusion and questions about his health began to mount.

Deputy Prime Minister David Levy, Shamir's chief rival, added to the confusion in a television interview last night in which he said Begin's powers had been "transferred" to him. The suggestion that he was now acting prime minister was denied by Meridor, Justice Minister Moshe Nissim and other legal experts, who said only the Cabinet had authority to replace a prime minister who is unable to function.

This morning, in a front page article in the independent newspaper Haaretz, columnist Yoel Marcus, quoting "close friends of the prime minister," said that since announcing his resignation Begin "has not shaved, hardly eats any more, doesn't want to meet anybody except his private secretary, relatives and doctors."

Marcus said Begin "seems to have lost interest in life to such an extent that friends and rivals alike are wondering whether he is considering suicide."

The article produced a furor and a bitter reply by Matti Shmuelevitz, director-general of Begin's office, that showed the deep animosity that has existed between the Begin government and that generally critical Israeli establishment of which Haaretz, the country's dominant newspaper, is a part.

Shmuelevitz said Marcus' report and another in Haaretz "not only do not conform with the facts, but illustrate the norms of vulgarity and crudity which have taken root in our lives in recent years.

"Unrestrained provocations against Mr. Menachem Begin have continued to appear in Haaretz, which presents a guise of fairness, seriousness and reasonableness, ever since the 'upset' of 1977," when Begin was first elected, he said. Haaretz, Shmuelevitz added, "has introduced a style of journalistic hooliganism into our lives. This style more than anything else has turned us into a violent society."

Begin's deterioration began Nov. 14 when Aliza, his wife of 43 years, died while he was in the United States. He rushed back to Israel, his personal loss compounded by the deaths earlier that month of 75 Israeli soldiers and border guards in an explosion in an Army building in Tyre, Lebanon.

From that point on, Begin grew increasingly reclusive, seldom appearing in public. His aides acknowledged his despondency, but they insisted he was alert and performing his duties.

The prime minister, who appeared pale, thin and weak, finally decided last month that he could not function properly, which is the only explanation he offered to the Cabinet when he announced his resignation.

Throughout this agonizingly slow process, Begin's aides have sought to protect him. In a telephone conversation last night, Meridor was pressed for details on Begin's condition. "Maybe I can tell you later, but not now," he said.

Told that from the outside it appeared a very sad situation had developed inside the prime minister's house on Balfour Street, Meridor replied, "It is."