The Man Who Would Be King tells the story of two British adventurers in British India who become kings of Kafiristan, a remote part of Afghanistan. It was inspired by the exploits of James Brooke, an Englishman who became the "white Raja" of Sarawak in Borneo, and by the travels of American adventurer Josiah Harlan, who claimed the title Prince of Ghor.
The story was first published in The Phantom Rickshaw and other Tales (Volume Five of the Indian Railway Library, published by A H Wheeler & Co of Allahabad in 1888). It also appeared in Wee Willie Winkie and Other Stories in 1895, and in numerous later editions of that collection. It is the basis for John Huston’s 1975 film of the same name, starring Sean Connery and Michael Caine as the "kings", and Christopher Plummer as Kipling. (Interim summary by Wikipedia adapted by Philippa)