Moshe Dayan, one of the last larger-than-life heroes in the 33-year history of Israel, and also one of its most enigmatic and controversial political figures, died tonight in a hospital near Tel Aviv after being admitted for an apparent heart attack. He was 66.

Dayan, a member of Israel's parliament, the Knesset, for more than two decades and the holder of some of the highest posts in Israel's government, died as the head of a small and relatively ineffectual opposition party he formed 1 1/2 years after resigning his job as Israel's foreign minister in a policy dispute with Prime Minister Menachem Begin.

His death nevertheless stunned Israel tonight, partly because of its suddenness and partly because Dayan had become a political fixture, loved and admired for his role in the shaping of the modern Jewish state, but at the same time evoking emotional countercurrents because of his mercurial shifts in allegiance.

Death came at 8:30 p.m. (2:30 p.m. EDT), shortly after the start of the Jewish sabbath. Begin announced that a state funeral will be held Sunday. Burial is expected to be in the farm village of Nahalal, west of Nazareth, where Dayan grew up and where his Russian-immigrant parents are buried.

It was well known that Dayan was suffering gravely from the ravages of stomach cancer -- his gaunt appearance left little doubt of that -- but few Israelis were prepared for the abrupt radio announcement of his death tonight.

Dayan was admitted to the Sheba Medical Center near Tel Aviv in the early morning hours today, complaining of chest pains and difficulty of breathing.

In the first of three medical bulletins, Dr. Bolaslav Goldman, director of the hospital, said that tests had shown that Dayan was not suffering from "the same problem" for which he was admitted in June 1979, when he was operated on for stomach cancer. In a noon bulletin, Goldman reported that Dayan was sitting up and reading newspapers and listening to the radio, but early this evening the hospital confined itself to reporting that Dayan was "stable" and making progress.

"Dayan still represented the first generation of those who fought for and built up the state of Israel," said Uri Porath, Begin's spokesman, who said the cause of death was a heart attack.

Shimon Peres, chairman of the opposition Labor Party, said Dayan was "a great Jew, a brave fighter and an original statesman has passed. His whole life was identified with the state of Israel. He acted and fought for it in his own way. Dayan astounded the whole world with his extraordinary capabilities."

In Washington, Israeli Ambassador Ephraim Evron declared, "Moshe Dayan was one of Israel's most outstanding sons. A farmer who toiled the arid land and made it bloom. A fearless soldier who fought for Israel's independence and then shaped its defense forces and led them in victorious battles of survival against overwhelming odds. A statesmen who as minister of foreign affairs played a key role and worked tirelessly to bring about the Camp David accords, and the peace treaty with Egypt."

United Press International reported that Dayan wrote for today's edition of the newspaper Yedioth Ahronoth, urging Israel to remain committed to its peace treaty with Egypt after the death of Egyptian president Anwar Sadat. "The agreement should be stuck to and not allowed to fall," he said.

Dayan's death came on the eighth anniversary of the day that Israeli Army troops, under the command of then-defense minister Dayan, crossed the Suez Canal and turned the tide in the 1973 war with Egypt. As it happened, Sadat, commander-in-chief of the Egyptian Army and Dayan's chief antagonist in that war, was assassinated on the anniversary of the Egyptian crossing of the Suez.

Dayan's death also came hours after the Israeli government announced that it intends to declassify and publish the much-awaited Agranat commission report on Israel's military preparedness and conduct in the 1973 war, when Dayan was responsible for the nation's defenses. The widely held view in Israel has been that the Agranat report was critical of Dayan's role as defense minister.

Long after that bitter conflict, Dayan remained a central topic of debate in Israel. Many of his critics bitterly recall that he took credit for the 1967 six-day war victory, which others had planned before he became defense minister -- three days before the war started. The critics also have been relentless in pointing out that Dayan heaped blame on the highest military echelons for the enormous losses in 1973, and that after the Labor Party's first election defeat in 1977 he bolted the party without explanation and joined Begin's rightist government.

In keeping with his maverick image, Dayan quit Begin's Likud government in October 1979, saying he could not remain as foreign minister because he and Begin differed "fundamentally" in their concepts of the future political status of the occupied West Bank and Gaza Strip.

Last April, Dayan formed a new election ticket, called the Telem (National Renewal) Party, and ran on a platform of unilaterally imposing autonomy on the 1.3 million Palestinians in the West Bank and Gaza Strip. His party won only two of the 120 seats in the Knesset, and Dayan seemed to withdraw from day-to-day Israeli politics, devoting much of his time to writing and promoting a new book.

The Telem Party has shown little influence in the Knesset, and just a month ago there appeared to be a tentative effort on the part of some members of the Labor Party to invite Dayan back into the fold of the party he abandoned in 1977. However, the movement -- begun by former members of the Rafi faction, which in the 1960s remained loyal to former prime minister David Ben-Gurion after he left the party -- was not able to enlist enough support to recall Dayan.

Dayan's death leaves former finance minister Yigael Hurwitz, who also quit Begin's Cabinet in a policy dispute, as the only Knesset member of the Telem Party. Former Likud Knesset member Zalman Shoval, who quit Begin's coalition after opposing the Egyptian-Israeli peace treaty, is expected to fill the Telem Party vacancy.