John G. Diefenbaker, 83, the Conservative prime minister of Canada from 1957 to 1963, died yesterday at his home in Ottawa following an apparent heart attack.

Mr. Diefenbaker was first elected to Canada's House of Commons in 1940. He retained his seat until his death, having been returned to Parliament by his constituency at Prince Albert on the prairies of Saskatchewan in the general elections of last May.

A flamboyant conservative and nationalist who was called "Dief the Chief" and "Mr. Conservative," he built his career on the promise of prosperity through the development of Canada's natural resources. The development, he said, should be by and for Canadians.

"I ask you to catch the vision -- the vast opportunities open to us as Canadians," he said over and over again.

Canada listened. Following a narrow electoral victory in 1957, he formed his first ministry as leader of the Progressive Conservative Party. This ended 22 years of rule by the Liberal Party. A cornerstone of Liberal policy had been close ties with the United States -- ties that were both economic and political and that had come to be taken almost for granted during World War II and the Cold War.

In 1958, Mr. Diefenbaker led his party to the largest electoral victory in Canada's history, winning 208 of 265 seats in the House of Commons. His administration was characterized by substantial economic growth at home, new programs to assist the prairie farmers, a plan to unlock the riches of the Canadian north, and an increasing independence from Washington.

Although staunch in his anticommunism, Mr. Diefenbaker authorized massive grain sales to mainland China despite objections from the United States. He refused to allow Canadian forces to be armed with nuclear weapons provided by the United States. He refused to break diplomatic relations with Cuba after the Communist takeover there, and he refused to bring Canada into the Organization of American States.

The Diefenbaker administration thus marked a step away from Canada's dependence on its neighbor to the south. But some of his policies were factors in Mr. Diefenbaker's eventual fall from office. His intrasigence on the question of nuclear weapons was exploited by the Liberal Party under the leadership of Lester B. Pearson, a diplomat of world reputation and a Nobel Peace Prize winner, in the 1963 elections that returned the Liberals to power.

Four years later, Mr. Diefenbaker suffered a defeat at the hands of his own party when Robert Stanfield defeated him for its leadership.

Through the years in which first Pearson and then Pierre Elliott Trudeau held the premiership, Mr. Diefenbaker kept speaking from the Front Bench of the opposition in Parliament. He remained as acid-tongued as ever, a familiar figure on the floor of the House, with his piercing blue eyes, his expressive face and his steely white hair.

As his support in Parliament dwindled, Canada took him to its heart in another way. He had left office before the great surge of Quebec separatism in the late 1960s and the new wave of political and cultural nationalism of which Trudeau became a spokesman in the 1970s, and Mr. Diefenbaker became a kind of nationalist talisman for many Canadians.

He published two volumes of memoirs that became best-sellers, and he was the star of a 3-part series of reminiscences televised by the publicly owned Canadian Broadcasting Corp. in 1976. The programs were among the most popular in Canadian history, hockey games apart.

Mr. Diefenbaker recalled his opposition to the adoption of the Canadian "maple leaf" flag on the grounds that it weakened symbolic ties to Great Britain. He recalled his close relations with president Dwight D. Eisenhower ("We were on an Ike-John basis and as close as the nearest telephone"), and his strained relations with president John F. Kennedy. But he asserted that a story that Kennedy had referred to him as "an S.O.B." in a note pencilled on the margin of a memorandum inadvertently left at a conference table by the president was an invention of his enemies.

Mr. Diefenbaker made his last appearance on television Saturday.

"I'm greatly concerned about my country," he said. "I have never seen it as divided as today. Suspicion, fear, all those things that deny unity are present."

News of Mr. Diefenbaker's death brought messages of regret from Joe Clark, the 39-year-old Progressive Conservative leader who became prime minister last May, from Queen Elizabeth II and other leaders.

"He was undeniably a national figure," said Clark, a boyhood admirer of Mr. Diefenbaker, who later became the object of his criticism. "His imprint on his nation is permanent and all of us who were privileged to work with him know that we will never see his like again. We have lost a rare man."

The queen issued a statement through Buckingham Palace in which she said, "Canada has lost a man of great stature. He never wavered. He was unfailing in his loyalty to his country and to the crown."

A spokesman for the Secretariat of the British Commonwealth, which is based in London, said Mr. Diefenbaker "had a vision of what the Commonwealth could become." He recalled that the Canadian leader was among the group who barred the Republic of South Africa from membership in the Commonwealth because of South Africa's apartheid policies.

The Canadian government announced Mr. Diefenbaker's body would lie in state in the rotunda of the Parliament Building on Friday.

John George Diefenbaker was born at Neustadt, Ontario, on Sept. 18, 1895. His father, a schoolteacher, was of Dutch descent and his mother was Scottish. When the boy was 8, the family moved to the prairies of Saskatchewan to try its hand at homesteading. The boy grew into a man of the prairies and for the rest of his life exemplified the ornate and florid tradition of prairie oratory, rather than the quiet tones of the business establishment in Toronto and Ontario.

He graduated from the University of Saskatchewan in 1916 and then joined the Canadian Army and served in France during World War I. He later earned a law degree and set up a practice in the village of Wakaw, Saskatchewan.

He became one of the best known trial lawyers in western Canada, and it is said that he once threw himself on the floor of a courtroom in British Columbia to demonstrate to the judge and the jury how a murder had been committed.

Mr. Diefenbaker was defense counsel in 20 murder cases, and only two of his clients went to the gallows.

Mr. Diefenbaker went into politics in the 1920s. By the late 1930s, he had become the provincial Conservative leader. He was elected to Parliament by the Lake Centre constituency in Ottawa in 1940, and in 1953 switched to the Prince Albert seat in Saskatchewan. He became leader of the Progressive Conservatives at a party convention in 1956.His career as prime minister began the following year.

"Ah, I love Parliament," Mr. Diefenbaker used to say.

On hearing of his death, Water Baker, a Conservative Party spokesman said, "I think that Parliament without his voice and presence is difficult to imagine."

Mr. Diefenbaker was twice a widower. His first wife, Edna Mae Brower, died in 1950. His second wife, Olive Evangeline, died in 1976. He had no children.