Ferenc Nagy, 75, the last non-Communist prime minister of Hungary, died Tuesday at Fairfax Hospital after a heart attack. He had lived in exile in Herndon since 1948.

Mr. Nagy was a leader of the democratic coalition Smallholders' Party in postwar Soviet-occupied Hungary. In 1946, his party won Hungary's only free postwar election with 57 percent of the vote.

The Communists, who had received only 17 percent of the vote, soon began purging anti-Communist members of the Smallholders Party. Mr. Nagy managed to survive until 1947, when the Russians presented charges to the Hungarians government led by President Zoltan Tildy involving Mr. Nagy in an alleged plot to overthrow the government.

On May 30, 1947, while Mr. Nagy was vacationing in Switzerland, the Hungarian Communist Party, backed by the Red Army, seized control of the government in a coup d'etat that resulted in the complete Communist state of Hungary.

Mr. Nagy was forced to resign in exchange for the life of his 4-year-old son, Laszlo, who had been left behind in Hungary and was being held hostage by the Communists. Mr. Nagy had been prime minister for 16 months.

He was replaced by Lajos Dinnyes, a pro-Communist member of his own coalition party who had served him as war minister.

Shortly after coming to this country, Mr. Nagy said in interviews that he had tried to cooperate with Soviet occupation forces only to find the Communists were looking not for cooperation but for power.

Mr. Nagy was born in Bisse, in Southern Hungary, on a 10-acre farm his family had worked for 300 years. Self-educated he worked on the farm until 1932, when he became national secretary of the Smallholders' Party. The Party drew its support from the peasant population, which made up more than half of Hungary's population.

In 1944, he was arrested by the German Gestapo and imprisoned. He later escaped and worked in the underground until the end of the war. Before being elected prime minister he served as minister of reconstruction.

Mr. Nagy and his family came to the United States from Switzerland on June 14, 1947, and moved to Herndon the following year. His son, Laszlo, had been freed to join him in Switzerland.

He bough a 12-room house and a 130-acre dairy farm in Herndon from his earnings as a writer and lecturerafter coming to this county. He worked part-time as a farmer for a time and became active in Hungarian exile groups. He seved as president and chairman of the Assembly of Captive European Nations.

During the 1956 Hungarian revolt, mr. Nagy remained uninvolved because, he said, he did not want to justify accusations that the revolution was started from the outside the country.

Mr. Nagy contributed political pieces to American newspapers and magazines and frequently lectured at colleges around country.He was the author of "The Struggle Behind the Iron Curtain," published by Macmillan in 1948. He retired from the lecture circuit about six years ago.

Survivors include his wife, Julianna, of the home; three daughters, Sophie, and Susan, both of Oakton, Va., and Julianna Pishsky, of Annandale; two sons, Ferenc Jr., of Bedford, Mass., and Laszlo, of Nashua, N.H., and seven grandchildren. CAPTION: Picture, FERENC NAGY