Vaclav Havel, a Czech writer who was imprisoned by his country’s communist rulers, only to become a symbol of freedom and his nation’s first president in the post-communist era, died Dec. 18 at his weekend home in the northern Czech Republic. He was 75.

The death was announced by his assistant, Sabina Tancevova, the Associated Press reported. Mr. Havel underwent surgery for lung cancer in 1996 and had suffered from lung ailments in recent months.

Mr. Havel was a playwright by profession and a political activist by avocation. The two activities were complementary, and each served to gain him a leading place among the dissidents of Eastern Europe who helped bring down the communist empire. His words and deeds resonated far beyond the borders of the former Czechoslovakia, and he was widely recognized for his struggles in behalf of democracy and human dignity.

After being unanimously elected president of Czechoslovakia by the newly free country’s Parliament in December 1989, Mr. Havel set the tone of the new era in a speech Jan. 1, 1990, his first day in office. Communism, he said, was “a monstrous, ramshackle, stinking machine” whose worst legacy was not economic failure but a “spoiled moral environment.”

“We have become morally ill because we are used to saying one thing and thinking another,” he said. “We have learned not to believe in anything, not to care about each other. . . . Love, friendship, mercy, humility, or forgiveness have lost their depths and dimension. . . . They represent some sort of psychological curiosity, or they appear as long-lost wanderers from faraway times.”

In July 1992, he resigned the presidency when it became clear that the country would be dismembered, with the Czech Republic and Slovakia, its eastern neighbor, going their separate ways. The split became formal on Jan. 1, 1993. About three weeks later, the new Czech Parliament called on the country’s most famous citizen to return to the presidency. He remained in office for 10 more years.

Although his office was largely ceremonial, Mr. Havel had wide-ranging influence. He was credited with a major role in providing political stability as the country’s economy made a relatively trouble-free transition from communist central planning to a free market. In foreign affairs, he was influential in gaining his country’s admission to the North Atlantic Treaty Organization.

But it was as a dissident that Mr. Havel first gained the world’s attention. For more than two decades, beginning in the 1950s, his books and plays were banned in Czechoslovakia. They nonetheless reached a large audience through the underground publishing network and broadcasts by the BBC and Voice of America.

The regime’s repeated denunciations also spread Mr. Havel’s fame and contributed to his influence. In 1977, he became the most visible member of Charter 77, a Czech human rights movement that protested the communist regime’s violations of human rights.

The price he paid was repeated incarceration. He was imprisoned from 1979 until February 1983, when he was released for health reasons. Just before assuming the presidency, he was held again for four months, for taking part in a prohibited demonstration marking the anniversary of the death of Jan Palach, the youth who set himself on fire to protest the Soviet invasion of 1968.

Although he claimed to be reluctant to pursue a political career, Mr. Havel helped found the Civic Forum in November 1989, the first legal political opposition to exist in Czechoslovakia since the communists took power in 1948. With its Slovak counterpart, Public Against Violence, the Forum staged large-scale demonstrations and entered negotiations with the government.

The president at the time was Gustav Husak, who had been a communist leader since the Soviet-led invasion of August 1968. The brutal invasion, which saw Russian tanks rolling through the streets of Prague, snuffed out a period of liberalization known as the Prague Spring and “socialism with a human face.”

Husak resigned in December 1989. Alexander Dubcek, the Communist Party leader during the Prague Spring, was rehabilitated after two decades in the political wilderness and presided over the national parliament. When he called for nominations for a new president, Mr. Havel’s name was the only one put forward.

From the beginning, Mr. Havel made it plain that his would be a new kind of government. Among his first actions was the appointment of outlandish U.S. rock musician Frank Zappa to be a “special ambassador to the West” on trade and tourism, prompting an incensed U.S. Secretary of State James A. Baker III to say, “You do business with the United States or you can do business with Frank Zappa.” Mr. Havel had been an admirer of Zappa and his band, the Mothers of Invention, since the 1960s.

Mr. Havel’s most difficult problem was the economy, and it was an important factor in the breakup of Czechoslovakia in 1992. As Prague began moving toward a market system, conservatives accused Mr. Havel of being a “crypto-socialist” because he insisted the government still had a planning role. Those on the left claimed he was pushing privatization of industry too fast. Many in Slovakia, always the poorer part of the country, thought they were suffering disproportionately.

Mr. Havel also was criticized for his opposition to a law that deprived former communist officials of their civil rights whether or not they had engaged in human rights violations.

Although most Czechs could scarcely imagine anyone else in the presidency, Mr. Havel’s popularity eroded over the years. When the parliament elected him to a second five-year term in January 1998, it was by a single vote.

His growing disfavor among the Czech public was attributed to politics and to Mr. Havel’s own health problems and personal behavior. He was criticized for his marriage in 1997 to Dagmar Veskrnova, an actress 17 years his junior, who survives him. They were married less than a year after Mr. Havel’s first wife, Olga Splichalova Havlova, died of cancer. She had been revered for her charitable work and for standing by her husband during the country’s many years of communist oppression.

The media suggested that Dagmar Havlova was unsuitable to be first lady of the republic, and some of that criticism rubbed off on Mr. Havel. When a conservative politician denounced him during a parliamentary session in the ornate Spanish Hall of Prague Castle, Mr. Havel’s wife responded with a derisive two-fingered whistle.

The incident received sensational coverage in the Czech media, but Mr. Havel told Czech Television:

“It was a completely unusual, completely spontaneous and completely spirited response, and it did a little to save the honor of those who had been forced to sit and listen to all the lies.”

Vaclav Havel was born in Prague on Oct. 5, 1936. His father was a successful real estate developer, but when the communists came to power in 1948, the family’s prosperity abruptly came to an end.

In “Disturbing the Peace,” a memoir published in 1990, Mr. Havel said the new regime “confiscated all our family’s property and we became objects of the class struggle.”

As a teenager, Mr. Havel began the intellectual and artistic journey that would make him famous. In 1950, he got a job as a stagehand at the ABC Theater in Prague, an experience that convinced him that a theater “must be a living spiritual and intellectual focus, a place for social self-awareness.”

After studying economics at the Czech University of Technology, he served in the army and in 1960 joined the Theater on the Balustrade. The theater continually tested the limits of Czechoslovakia’s cultural freedom, helping bring about the cultural thaw that culminated in the Prague Spring. In 1963, it produced Mr. Havel’s first full-length play, “The Garden Party,” an absurdist satire of the bureaucracy and the distortion of language.

In his 1965 play, “The Memorandum,” an official tries to comply with a decree ordering the use of a new “scientific” language called Ptydepe — with the result that no one understands anything. In 1968, he wrote “The Increased Difficulty of Concentration,” a bedroom farce that made the point that the human heart cannot be understood by computers.

After being staged in New York, “The Garden Party” and “The Memorandum” won Obie Awards in 1968 and 1970. Mr. Havel’s other major works included 1984’s “Largo Desolato,” about someone accused of “intellectual disturbance of the peace”; “Temptation,” a version of the Faust tale; and three one-act plays about the struggle between conscience and conformity in the face of oppression: “Interview,” “A Private View” and “Protest.”

In January 1968, Dubcek succeeded the hard-line Antonin Novotny as chief of the Czechoslovak Communist Party.

With the Soviet invasion in August 1968, the liberal Dubcek was succeeded by Husak, a Communist Party apparatchik. Mr. Havel took part in Free Czechoslovak Radio broadcasts and signed a petition protesting Husak’s policy of “normalization,” as his program of repression was called.

In retaliation, the regime suppressed his writing and banned him from working in the theater. Although he was arrested several times and was under nearly constant surveillance, he continued to write. His work was published — and sometimes performed — clandestinely.

In April 1975, Mr. Havel wrote an open letter to Husak warning that the oppressed people of Czechoslovakia would demand redress for “the permanent humiliation of their human dignity.” Mr. Havel was arrested and detained again.

In the late 1970s, the Czech government cracked down with a wave of arrests and warnings that “freedom of expression” had to be “consistent with the interests of the working people.”

In 1978, he helped found an offshoot of Charter 77 called the Committee for the Defense of the Unjustly Persecuted, which resulted in a 41 / 2-year sentence in 1979.

During his imprisonment, Mr. Havel wrote many letters to his wife, which were collected as “Letters to Olga.” Published in English in 1988, they were praised by the Times of London as the work of a “profound philosopher.”

J.Y. Smith, the former obituaries editor of The Washington Post, died in 2006. Staff writer Matt Schudel contributed to this report.