Every time he seemed finished, the perma-tanned premier managed to miraculously bounce back.

But he just couldn't beat the markets.

Berlusconi announced Tuesday he would resign after parliament passes economic reforms demanded by the European Union. He acted in the face of a relentless investor attack on Italy's government bonds and crumbling support in parliament, almost certainly ending a political career in which he achieved the feat of becoming his nation's longest-serving premier.

The media baron dominated Italian politics for nearly two decades. He served as premier three times over the past 17 years -- a charismatic if polarizing figure who sold Italians a dream of prosperity with his own personal story of transformation from cruise-ship crooner to Italy's richest man.

But in his last years in power, he became almost a grotesque caricature of the charming billionaire who cast a spell over his nation.

The hair transplants and plastic surgery became all too obvious. His reputation as a seducer gave way to allegations of trysts with prostitutes and underage girls. He embarrassed Italy with jaw-dropping gaffes at international summits.

Accusations grew that he was in politics not for Italy's sake but for his own -- to boost his business interests and change laws to shield himself from prosecution.

As pressure for his resignation grew, he remained defiant, labeling opponents "communists" to be kept at bay and prosecutors as "terrorists" defying the will of the people who elected him.

Even as his allies were defecting, he anointed himself Italy's savior at the close of the Group of 20 summit in Cannes, France, last week.

"I feel a duty to continue these things," he said. "This is a great duty and sacrifice for me. Here, at the Cannes summit, I looked around and I don't see anyone in Italy who is up to representing our country. I asked myself, you could represent Italy if I weren't there?"

But he had only so many political lives. The magnetic smile, the confident wisecracking, the perennial optimism were no longer reassuring.

When Italy became the new focus of the eurozone debt crisis, the financial markets delivered their verdict: Berlusconi himself was the problem. He lacked the political clout to quickly pass the needed measures to boost growth and cut debt. To use a metaphor from his beloved sport of soccer, it was game over.

But ousting Berlusconi wasn't easy.

"He's not the retiring type. ... It's very much a personal trait, he really thinks he's the best in the world," said James Walston, a professor of political science at Rome's American University.

The ultimate fear that clinched political change was that Italy would not be able to pay for its enormous €1.9 trillion ($2.6 trillion) debt. That is too expensive for Europe to handle, and could trigger a default that would break up the 17-nation eurozone and drag down the global economy.

Berlusconi had used television and his own wealth to build a political career. He boasted of his riches and kept a lavish lifestyle that included partying with young women.

"I'm no saint," he said defiantly after his wife of almost 20 years announced she was seeking a divorce in 2009.

But the scandals picked up steam. First a self-described call girl said she went to bed with Berlusconi on the night that Barack Obama was elected U.S. president.

Then came embarrassing criminal charges that he had sex with an underage Moroccan girl nicknamed Ruby Rubacuori ("Rudy the Heart-Stealer) and used his office to cover it up. The trial is in progress.

While he repeatedly denied any wrongdoing, the 75-year-old Berlusconi was becoming increasingly reclusive in public as he sought to defend himself in three trials and several other criminal investigations.

The trials -- the sex case, tax fraud and corruption -- will continue but once out of office he will lose the ability to delay hearings as he has been doing, citing conflicts with official business.

Berlusconi had the power to inspire both fierce loyalty and equally fierce opposition. To his admirers, the conservative leader was a capable statesman who sought to make Italy rich and powerful. To his critics, he was a populist whose immense media and political power made him a threat to democracy.

That was perhaps never more apparent than when Berlusconi was attacked by an unstable man during a political rally in Milan in 2009
.
The attacker threw a souvenir statuette of Milan's cathedral at the premier's face, leaving him with a fractured nose, two broken teeth and lip cuts. Images of Berlusconi's bloody, shocked face drew sympathy and solidarity even among critics, but his attacker also generated a storm of praise on Facebook and YouTube.

Berlusconi often boasted of his success with women. He entertained friends and world leaders alike at his villas on the Emerald Coast of Sardinia. Scores of young women frequently attended: On one occasion, Italian newspapers reported, the girls were all dressed as "little Santas."

Berlusconi was famously nicknamed "Papi" (or "Daddy") by a Neapolitan girl whose 18th birthday party he attended in 2009, an appearance that initiated a spate of sex scandals and left his wife so furious that she filed for divorce soon afterward.

Berlusconi reveled in straying from political etiquette.

He once famously sported a bandanna when receiving British Prime Minister Tony Blair in Sardinia. (The reason, it turned out later, was to conceal a recent hair transplant.)

He posed for an international summit's family photo making an Italian gesture -- which can be offensive or superstitious depending on the circumstances -- in which the index and pinkie fingers are pointed like horns. He made German Chancellor Angela Merkel wait while he chatted on his mobile phone during a NATO summit.

And he caused an international outcry in 2003 when he compared a German EU parliament lawmaker to a Nazi camp guard.

Berlusconi became rich after breaking the state monopoly on television in the late 1970s. Twenty-five years later his Mediaset network was a cash cow thanks to game shows, scantily clad girls and imported U.S. sitcoms in deals that were the source of some of his criminal prosecutions. Together with the state network that he effectively controlled as premier, he held 90 percent of Italy's TV market.

When the "Clean Hands" corruption scandals broke in the 1990s, wiping out the entire political establishment, he founded his own party in 1994 and named it after a soccer cheer: Forza Italia. He was elected premier three months later by Italian seeking a break from the past.

That government was short-lived after his Northern League ally pulled out later that year. But he was re-elected two more times: in 2001, when his government served out an entire 5-year term, and again in 2008.

Summing up his appeal, he said: "Most Italians in their hearts would like to be like me and see themselves in men and in how I behave."

But that appeal, according to all opinion polls, began to wane when the economy failed to grow, unemployment began creeping up, and job prospects for young people disappeared.

At the same time, he was devoting much of his political capital to protect his own interests, including a bill to shorten the statute of limitations and another that would have provided him with immunity from trials. It was overturned by the Constitutional Court.

Even as the debt crisis worsened, he pushed legislation to limit publication of wiretaps before trial, citing himself and other prominent people as victims, and tried to include a measure in an austerity package that would have allowed his family investment company to dodge a heavy fine.

Berlusconi's departure leaves major questions about the future of his party. It has been weakened by prominent defections and he himself had repeatedly said he would not seek re-election. His hand-picked successor, his former justice minister Angelino Alfano, lacks Berlusconi's dynamism.