WARSAW, Poland -- Tadeusz Mazowiecki, Eastern Europe's first democratic prime minister after communism, key adviser to Poland's Solidarity freedom movement and UN human rights envoy to Bosnia in the 1990s, has died. He was 86.

Mazowiecki's personal secretary, Michal Prochwicz, told The Associated Press that the former prime minister died early Monday in hospital. Prochwicz said Mazowiecki was taken to hospital on Wednesday, with high fever.

A lawyer by training, a writer and thinker by temperament, Mazowiecki was well equipped for his role in ousting communism from Poland and shaping a democracy. As prime minister, he called for drawing a "thick line" to separate the communist past from new Poland, a much-criticized position which contributed to his ouster after a year in office.

He made a crucial decision in August 1980 to join thousands of workers on strike at the Gdansk Shipyard to demand restitution of a job for fired colleague, Anna Walentynowicz, better pay and a monument to workers killed in the 1970 protest. Within days, their action grew into a massive wave of strikes that gave birth to Solidarity, Eastern Europe's first free trade union and a nationwide freedom movement, led by a charismatic shipyard electrician, Lech Walesa, whose name quickly became known around the globe.

Walesa later said that "everybody was very glad that the intellectuals are with the workers. It was a very important signal for the authorities."

From the days of the strike until well into Poland's democracy in the 1990s, Mazowiecki was among Walesa's closest counsellors. He advised Walesa in the tough yet successful negotiations with the communists, who granted union and civic freedoms in 1980.

He shared Walesa's lot in the bleak days of martial law that Gen. Wojciech Jaruzelski imposed on Dec.13, 1981, to curb the freedom that had irritated Moscow. Under the military clampdown Solidarity was outlawed, the economy stagnated and Walesa, his advisers, and hundreds of Solidarity activists were imprisoned for many months.

Mazowiecki spent one year in confinement. When released, he returned to Walesa's side and also wrote analytical reports about the deep stagnation of social and economic life under the rule of the military.

The hardships, shortages and a lack of prospects inspired a new wave of strikes in 1988. Mazowiecki walked arm in arm with Walesa at the head of angry workers marching through the streets of Gdansk. The protests brought the communists to the negotiating table to discuss the terms of democratization with Walesa, Mazowiecki, and other Solidarity leaders. Mazowiecki authored many of these terms.

The outcome was Eastern Europe's first partly free parliamentary election. The June 4, 1989, vote gave Solidarity seats in parliament and --hard to believe at the time -- paved the way for the first democratic government in the cracking communist bloc. In September, Mazowiecki became the region's first democratic prime minister. A popular picture in which he flashes a V-for-victory sign to the chamber became the symbol of Poland's triumph over the oppressive communism.

Mazowiecki began working as a journalist and editor for Catholic magazines in the late 1940s. A declared believer, he undertook the impossible task of carving a space for ethics and religious views in politics under the anti-church communist system, imposed on Poland as a result of World War II.

In the 1960s he served as a Catholic lawmaker, but his protest in parliament against use of force on protesting students in 1968 and his demands for explanations of the deaths of dozens of shipyard workers protesting price hikes in 1970 provoked the communist authorities to expel him from his seat.

The 1970s marked Mazowiecki's growing involvement in independent, often clandestine think tanks that educated Poles toward democracy and civic rights. Mazowiecki supported and advised workers' protests -- still few at the time and kept secret by the communists.

Poland's peaceful revolution set in motion rapid freedom changes in other countries of the region -- climaxing in the fall of the Berlin Wall in November 1989.

Usually serious and pensive, Mazowiecki showed a flash of humour during his historic policy speech in parliament, when he suddenly felt faint. Returning to the floor after a lengthy break, he drew applause by saying that the stress and hard work had brought his condition down to the level of Poland's dilapidated economy.

His government was hastily composed of Solidarity backers, who were experts in their fields but had no experience in running a country. Still, they accomplished a milestone task: in a matter of months they laid foundations for a new democratic state.

"I had this very strong conviction that we will make it, that we will be able to build the foundations of a new state on those ruins. That we must be successful," Mazowiecki said in a 2004 interview.

The finance minister, Leszek Balcerowicz, gained universal respect for his unprecedented plan of stringent economic reforms that halted rampant inflation, made the local currency -- the zloty -- convertible, curbed central governance and paved the way for private business and for a market economy. The painful effect was a sudden, high unemployment from closed steel mills and state-run farms, which still clouds Balcerowicz's reputation in Poland.

Mazowiecki also was accused of leniency for the communists, and many thought the "thick line" amounted to turning a blind eye to past evils. In retrospect, he believed his phrase was "right and wise."

"It offered democracy to the Poles, to all Poles, without dividing them into better and worse, into party members and the non-aligned," Mazowiecki told Toranska. "This paragraph was announcing a change through evolution. Not a revolution, which has always led to witch-hunts in the past."

Mazowiecki's critics point to the general impunity of communist leaders, the authors of the martial law that led to the deaths of some 100 people. Jaruzelski was defendant in two trials --concerning martial law and the 1970 workers' deaths -- but they were discontinued due to his poor health before verdicts were reached. Only a handful of secret security agents have been brought to justice, while many communist-era politicians started successful businesses and are among the nation's richest people.

The price of the reforms was high. Mazowiecki's government stint ended abruptly when he unexpectedly lost in the 1990 first free presidential election to a complete unknown, a Polish emigre from Peru, Stan Tyminski. Walesa won in the runoff.

"This government's role was to make this painful beginning," Mazowiecki said in an address ending his 15-month term as the former East bloc's first non-communist leader. "We did not try to arouse hopes which could not be fulfilled."

In 1992 Mazowiecki was appointed the first UN envoy to war-torn Bosnia and widely reported on atrocities there. Angered by a lack of international reaction to the killings, which he termed as war crimes, he resigned in 1995 after the fall of Srebrenica. Serb troops overran the city and killed some 8,000 Muslim men and boys, despite Srebrenica being declared by UN forces as a safe heaven. At the time of Mazowiecki's resignation the UN was already seeking to react with force, but his move was an additional impulse, although seen by some as backing out.

Mazowiecki said at the time that his resignation was "all I can do for these people to tell the world, the Western and UN leaders that the situation cannot go on this way."

He continued as lawmaker and politician in Poland and co-authored the 1997 Constitution. He served as adviser to President Bronislaw Komorowski since 2010.

Mazowiecki was born April 18, 1927, in the central city of Plock to the deeply religious family of medical doctor, Bronislaw Mazowiecki. His father died in 1938.

In an interview for the Plock edition of Gazeta Wyborcza, Mazowiecki said he remembered going with his father to bakeries to have whipped-cream cakes. He also remembered being terrified of the dentist to the degree that anesthesia had to be used on him.

Under the Nazi German occupation of Poland during World War II, in which 6 million Polish citizens were killed, teenage Mazowiecki worked as a messenger for the city hospital and for a trade company. The Germans sent his older brother, Wojciech, to the Stutthof death camp. He never came back.

After the war, Mazowiecki studied law at the Warsaw University but did not obtain a degree, engaging instead in journalism and politics.

He was twice widowed. His first wife, Krystyna, died of tuberculosis within a year of their marriage. His second wife, Ewa, the mother of his sons Wojciech, Adam and Michal, died in 1970.