Moammar Gaddafi, Libya's strongman ruler, is commonly portrayed as an egomaniacal buffoon - an autocrat with an affinity for incomprehensible speeches and a flair for the melodramatic.

But as seen through a trove of confidential U.S. diplomatic cables disclosed by the anti-secrecy Web site WikiLeaks, the Libyan leader has another side: a master schemer who has dominated the country and its fractious tribes for four decades by successfully manipulating everyone around him.

Since reopening an embassy in Tripoli two years ago, U.S. diplomats have gradually come to express an understated admiration for Gaddafi's political skills. Even as they describe him as "mercurial" and "notoriously erratic," embassy officials document example after example of how the 68-year-old strongman has maintained his authority by skillfully marginalizing allies and rivals alike, including his power-hungry children.

Gaddafi "remains intimately involved in the regime's most sensitive and critical portfolios," Ambassador Gene A. Cretz wrote in a Jan. 28, 2009, cable to the State Department in Washington. He said the Libyan ruler's "mastery of tactical maneuvering has kept him in power for nearly 40 years."

Those skills have been on display in recent days as Gaddafi has tried to stave off a popular revolt by any means possible, including an all-out military assault on protesters and the deployment of foreign mercenaries. In a rambling televised address Tuesday from the heart of Tripoli, he ranted against his enemies and vowed to fight "to my last drop of blood."

Since taking power in 1969, Gaddafi has successfully kept the rest of Libya's political establishment under his thumb. He abolished military ranks higher than the one he gave himself - colonel - and placed relatives and loyal members of his tribe in key military and government positions.

"The reality is that no potential successor currently enjoys sufficient credibility in his own right to maintain that delicate equilibrium," Cretz wrote. Gaddafi, he added, "is the architect of his own gilded cage and cannot yet relinquish day-to-day decisionmaking, even if he wants to."

While Gaddafi likes to portray himself to his people as "an oracle above the fray" in Libya's opaque governing structures, in reality he personally vets all government contracts above $200 million, handpicks officials throughout the bureaucracy and is generally well-versed in the minutiae of domestic and foreign policy, the cables assert.

Gaddafi's multifaceted personality was on full display during an Aug. 14, 2009, meeting in Tripoli with a U.S. congressional delegation. The lawmakers, led by Sen. John McCain (R-Ariz.), were summoned to Gaddafi's opulent tent at 11 p.m. The Libyan "appeared as if he had been roused from a deep slumber" and showed up with "rumpled hair and puffy eyes," according to a diplomatic cable summarizing the encounter. Wearing wrinkled pants and "a short-sleeved shirt patterned with the continent of Africa," Gaddafi's mercurial side seemed be in control.

But, the cable reported, Gaddafi "was lucid and engaged throughout the meeting," exhibiting a command of the issues at hand and a diplomatic manner. When his son Muatassim, who serves as his national security adviser, tried to interrupt the U.S. lawmakers, Gaddafi "shushed" him and bade the visitors continue.

To be sure, the cables are packed with colorful references to Gaddafi's eccentricities. A September 2009 embassy missive to Secretary of State Hillary Rodham Clinton noted that Gaddafi was no longer constantly accompanied by his "legendary" band of female bodyguards. Instead, he had become more heavily dependent on his Ukrainian nurse, a "voluptuous blonde" named Galyna, who traveled with him everywhere.

The cable also referred to Gaddafi's phobia about flying over open waters and his fear of staying on the upper floors of hotels when traveling abroad.

Gaddafi's health and personal appearance were common subjects of embassy analysis. A June 16, 2009, cable discussed speculation that Gaddafi had throat cancer and diabetes but dismissed the reports as "unreliable." It did conclude that he was a "hypochondriac" who ordered that all his physical exams be videotaped so he could review them with a variety of trusted doctors.

The same cable said some of Gaddafi's health problems could be attributed to his "extremely vain" personality. While some sources in Tripoli had whispered to embassy officials that Gaddafi's loss of control of his facial muscles was evidence he had suffered a stroke, others rejected that analysis, saying it was merely the result of excessive Botox treatments.

In addition, Gaddafi's scraggly hairline was blamed on a botched hair implant sometime in 2008 or 2009. The cable explained that he "suffered a rare auto-immune reaction to the procedure and the plugs had to be removed."

Of Gaddafi's eight children, several hold positions of influence. The embassy cables, however, concentrate their attention on two sons: Muatassim, the national security adviser, and Saif al-Islam, a British-educated engineer, who have been considered the most likely candidates to succeed their father as ruler.

Muatassim is derided in the cables as a shallow thinker who is not "intellectually curious" but has the support of many old-guard figures in Libya's security establishment. Saif al-Islam is presented as an urbane sophisticate who is much more comfortable meeting with Western businessmen and diplomats. Both sons, however, along with everyone else in Libya, are often left guessing at their father's true intentions, according to a November 2009 cable authored by Cretz.

"Qadhafi has placed his sons," he wrote, "on a succession high wire act, perpetually thrown off balance, in what might be a calculated effort by the aging leader to prevent any one of them from authoritatively gaining the prize."

Correspondent Sudarsan Raghavan in Sanaa, Yemen, contributed to this report.