Though it offers a powerful dose of uncomfortable entertainment, “The Last King of Scotland,” in typical Hollywood fashion, occasionally sacrifices historical accuracy to exalt sex and violence.

Inspired by true events, rather than based on them, and adapted from a novel of the same name, director Kevin Macdonald’s “The Last King of Scotland” is a powerful, uneasily enjoyable film about the charismatic, erratic and severely deranged Ugandan dictator Idi Amin. During his eight-year reign, the larger-than-life (and former heavyweight boxing champ) “Life President” became increasingly paranoid, and it is estimated that he is responsible for the deaths of at least 300,000 Ugandans. But the world, seduced by his outrageous humor and buffoonish charm, was easily blinded to his maniacal despotism.

This grossly compelling figure is embodied on-screen by Forest Whitaker in a performance so vigorous and commanding that critics are already buzzing about an Oscar nod. Whitaker’s dangerously imposing physical stature is in constant tension with his boyish smile and otherwise jocund features — a tension he fully capitalizes on to highlight the character’s complexity and duplicity. But for all Amin’s irresistibly playful charm (and sociopathic tendencies), Macdonald reveals a deceptively rational and sociopolitically savvy leader; Amin not only understands his country’s problematic relationship to British imperialism but is able to transform that understanding into a persuasive nationalist rhetoric.

But for all Whitaker’s gripping brilliance in bringing Amin to celluloid life, the story isn’t really his. “The Last King of Scotland” is told through the eyes of a young Scottish doctor named Nicholas Garrigan, played by the startlingly blue-eyed James McAvoy. After an exceptionally brief exposition — during which Nicholas’ dissatisfaction with the predictable trajectory of his life as a family doctor is established — he undertakes the grueling journey to Uganda in search of exotic adventures and, it seems, dalliances with married women. The idealistic young doctor arrives in Uganda on the very day in 1971 that Amin overthrows president Milton Obote, with plans to work at a rural clinic. Cinematographer Danny Boyle (“28 Days Later”) reflects Nicholas’ wide-eyed excitement through the use of an almost oppressively saturated palette and spells of frenzied cutting.

Soon after his arrival, however, Nicholas finds himself unwittingly taken under Amin’s expansive wing. Quick to abandon his post at the clinic, Nicholas slides easily into a life of opulence at the president’s palace in Kampala, dubiously serving as his personal physician. Juxtaposing the rural authenticity of his life at the clinic with the lavish parties and Mercedes-Benz convertibles of Kampala, Nicholas is a case study of good intentions gone awry. But Nicholas was not the only one seduced by Amin, and the young Scot’s naive, or perhaps just irresponsible, ignorance mirrors the rest of the world’s delayed recognition of Amin’s treachery. Macdonald here begins to probe questions of redemption: Are we ever really able to make amends for the mistakes and oversights we make in the foolishness of youth?

As Nicholas begins to realize the gravity of his situation, his peculiarly close relationship with Amin begins to deteriorate. Definitely inviting an Oedipal reading, the slowly building tension between the two men culminates with a frightening confrontation during which Amin demands of Nicholas, “How could you so disrespect your father?”

After so much is invested in fleshing out the intriguing psychological portraits of both Amin and Nicholas, it is a bit of a letdown to find out the film is only partially factual. Although loosely based on Bob Astles, known as Uganda’s “white rat,” Garrigan is a fictional character (but is tellingly referred to as Amin’s “white monkey” in the film).

An even more unsettling revelation, however, comes at the end of the film, when we are reminded that Amin died just over three years ago in exile in Saudi Arabia. Largely ignored by mainstream Western culture for the past three decades, the troubling tale of Idi Amin has at last found its way into American consciousness. Even if only in limited release.