In 1958 a show trial took place in communist Hungary. The accused were István Bibó, a minister in Imre Nagy’s last revolutionary coalition government and his friend Árpád Göncz, who has died aged 93. Bibó’s “crime” was authorship of a memorandum on the possible solution of the “Hungarian question”, of how to find a compromise between János Kádár’s regime, shored up by Soviet bayonets, and the national self-determination asserted by the 1956 revolution. Göncz’s “crime” was to send the Bibó memorandum abroad through diplomatic channels. Both men were found guilty and sentenced to life imprisonment. This was upheld by the appeal court and they remained in jail until an amnesty was declared in 1963.

With the ending of communist rule in Hungary in 1989, Göncz’s role in political life was transformed. Free elections were held the following year, and he served for a decade not just as the first president of the independent country, but as the most popular holder of the post to date.

Göncz was born in Budapest, the son of Lajos and Ilona (nee Heimann). During the second world war he worked for a banking organisation, the Hungarian Land Credit Institute, and studied law at Péter Pázmány University in the city. After graduating, he was enlisted in the army in February 1944, but deserted after the German occupation of Hungary and made contact with the resistance, signing up for the illegal anti-German Táncsics brigade of Hungarian students.

In 1945 he joined the Smallholders party, where until 1948 he edited the newspaper Nemzedék (Generation) and worked for its general secretaries, Béla Kovács and Zoltán Tildy. After the communist takeover he worked in several factories as a welder and tube-fitter; in 1951 he managed to secure a post as an agronomist. In 1952 he began studies at the Agricultural University of Gödöllő, but the upheavals that followed prevented him from completing his degree.

Göncz returned to politics in 1956. He took an active part in the debates of a discussion club called the Petőfi Circle. During the Hungarian revolution he joined the Peasant party and worked for the Hungarian Peasant Alliance; it was as a delegate of the Peasant party that Bibó entered Nagy’s last cabinet. Göncz was arrested in May 1957. At the ensuing trial, he was found guilty not only of sending Bibó’s manuscript abroad, but also of smuggling out of Hungary another manuscript, written by Nagy in 1955, which came to be published in the west as Imre Nagy on Communism, and is regarded as the revolutionary prime minister’s political testimony.

While imprisoned, Göncz followed the example of the 19th-century Hungarian statesman Lajos Kossuth and taught himself English. This helped him to earn a living as a translator after he regained his freedom. Between 1965 and 1990 he translated more than 100 English and American novels, including works by EL Doctorow, William Faulkner, William Golding, Ernest Hemingway, William Styron, JRR Tolkien and John Updike. His re-entry into politics took place in 1988 as co-founder of the Committee of Historical Justice as well as of the party of Free Democrats, becoming a member of its executive council in 1989. He was also elected president of the Hungarian Writers Association (1989-1990).

Göncz entered the first freely elected Hungarian parliament in May 1990, acting as its speaker and temporary president of the new republic for four months until confirmed in the post the following August. During his presidency he visited many foreign countries, including several visits to Britain, on one of which the Queen held a banquet at Windsor Castle for him and his wife, Mária (nee Göntér), whom he had married in 1946. For the first time in the history of such Anglo-Hungarian events, Göncz made his speech in Hungarian, with a printed English translation for the guests.

Göncz was a writer of both fiction and drama. His first novel, Sarusok (The Sandalled Ones), a historical parable, was published in 1974 and adapted for the stage in 1979. In the same volume were published the sombre monodrama Magyar Médeia (Hungarian Medeia) and Rácsok (Barriers), a play set in an unnamed country of South America, but probably based on Göncz’s own prison experiences. Notable among his later works are the surrealistic drama Pesszimista Komédia (A Pessimistic Comedy) and a collection of short stories, Hazaérkezés (Homecoming and Other Stories, 1991). A central issue both in his fiction and drama is the struggle of the individual against the challenge imposed upon him by society.

His many awards included the Albert Schweitzer prize, the Premio Mediterraneo (both 1991) and the Vision for Europe prize (2000), and the universities that gave him honorary doctorates included Brussels, Bologna, Connecticut, Oxford and New Delhi. After his retirement in 2000 he played no further active part in politics and while his 90th birthday was widely celebrated, in recent years illness compelled him to withdraw from public view.

What impressed people about Göncz was his natural friendliness, openness to criticism and adaptability. Never overrating the importance of his high office, he used his power judiciously, occasionally censuring prime ministers of various parties who were inclined to overstep their remit. His story was told in English by the Korean scholar Dae Soon Kim in The Transition to Democracy in Hungary: Árpád Göncz and the Post-Communist Presidency (2013).

On the several occasions that I met Göncz, both in Britain and in Budapest, he always received me with a ready smile and the handshake of a man who in politics managed to rise above past rancour and bitterness, willing to forgive his former jailers and demagogic, unfair opponents.

He is survived by his wife, two sons and two daughters.

• Árpád Göncz, politician, writer and translator, born 10 February 1922; died 6 October 2015