Sir Sidney Ruff-Diamond, Sid James, is Queen Victoria's Governor in Kalabar, a provincial outpost near the Khyber Pass. The region is defended by the feared 3rd Foot and Mouth Regiment, who are rumored to go into battle without any undergarments beneath their kilts. When a bumbling Private Widdle [Charles Hawtrey] is found wearing underpants after a confrontation with the warlord Bungdit Din [Bernard Bresslaw], leader of the Burpa tribe, the Khasi of Khalabar [Kenneth Williams] hatches a plan to use this embarrassing detail to spark a rebellion, attempting to debunk the "tough" image of the Devils in Skirts by proving that they do indeed wear underwear.
A cautious British diplomatic effort attempts to keep this information out of the public eye, but fails to publicly prove that the incident was merely a freak occurrence. The Governor's wife Lady Ruff-Diamond [Joan Sims] hopes to lure the Khasi by consummating a relationship, so she photographs an inspection in which many soldiers appear to be wearing underpants, and delivers the image to him. With hard evidence in hand, the Khasi would be able to assemble a formidable Afghan invasion force, sweep through the Khyber Pass, and seize India from the British. However, the plan stalls as Lady Ruff-Diamond is delayed by his reluctance, and he ultimately escorts her away to Bungdit Din's palace. Meanwhile, the Khasi's daughter, Princess Jelhi [Angela Douglas], confides in Captain Keene [Roy Castle]—a man she has fallen for—that the Governor's wife has eloped; a team is dispatched to ensure the return of both the wife and the photograph.
Disguised as Afghan generals, the would-be rescuers are admitted to Bungdit Din's palace and, on the Khasi's suggestion, introduced to Bungdit Din's sultry concubines. While enjoying the women in the harem, they are unmasked during a farcical orgy, imprisoned, and scheduled for execution at sunset alongside the Governor's wife. Princess Jelhi helps them escape by disguising them as dancing girls, but when the Khasi insists on seeing the dancing girls instead of the entertainers, their disguises are revealed. The British and the Princess flee, but Lady Ruff-Diamond drops the photograph as they leave the palace's gardens. The group makes haste for the Khyber Pass, only to discover that its guards have been massacred, and their weapons reflect a comically mangled state.
All attempts to hold off the Afghan invaders fail, and a hasty retreat is organized toward the Residency. The Governor, meanwhile, endures an indulgent evening with the Khasi's fifty-one wives, each eager to "right the wrong" they believe has been done against them by their husband and the Khasi. After a tense exchange, Sir Sidney calls a crisis meeting and resolves to "do nothing"—a decision that proves costly. A black-tie dinner is planned for the same evening. During this prolonged scene, the siege continues to unfold outside, while the attendees dine with little concern for the destruction around them. The fakir's severed head, still talking, is served as a grim garnish for the meal, courtesy of the Khasi.
Only Brother Belcher [Peter Butterworth] remains composed, until his nerves give way. Following Captain Keene's suggestion, the group steps outside to be greeted by a bloody battle in the courtyard. Still in black tie, Sir Sidney orders the Regiment to form a line and lift their kilts, this time exposing the (implied) underwear for all to see. The sight intimidates the Afghan army, which retreats in moments. The visitors return indoors to finish their dinner, while Brother Belcher remarks on the Union flag flown by the governor bearing the slogan "I'm Backing Britain."