Gilbert and Sullivan's previous opera, Princess Ida, ran for nine months; a short duration by Savoy opera standards. As Ida showed signs of flagging, producer Richard D'Oyly Carte realised that, for the first time since 1877, no new Savoy opera would be ready when the old one closed. On 22 March 1884, Carte gave Gilbert and Sullivan contractual notice that a new opera would be required in six months' time. Sullivan's close friend, conductor Frederic Clay, had suffered a serious stroke in early December 1883 that effectively ended his career. Sullivan, reflecting on this, on his own precarious health, and on his desire to devote himself to more serious music, replied that "it is impossible for me to do another piece of the character of those already written by Gilbert and myself". Gilbert was surprised to hear of Sullivan's hesitation and had started work on a new opera involving a plot in which people fell in love against their wills after taking a magic lozenge. He wrote to Sullivan asking him to reconsider, but the composer replied on 2 April that he had "come to the end of my tether" with the operas: “...I have been continually keeping down the music in order that not one [syllable] should be lost... I should like to set a story of human interest & probability where the humorous words would come in a humorous (not serious) situation, & where, if the situation were a tender or dramatic one the words would be of similar character.”
Gilbert was much hurt, but Sullivan insisted that he could not set the "lozenge plot". In addition to the "improbability" of it, it was too similar to the plot of their 1877 opera, The Sorcerer. The parties were at a stalemate, and Gilbert wrote, "And so ends a musical & literary association of seven years' standing—an association of exceptional reputation—an association unequalled in its monetary results, and hitherto undisturbed by a single jarring or discordant element." However, by 8 May 1884, Gilbert was ready to back down, writing, "...am I to understand that if I construct another plot in which no supernatural element occurs, you will undertake to set it? ...a consistent plot, free from anachronisms, constructed in perfect good faith & to the best of my ability." The stalemate was broken, and on 20 May 1884, Gilbert sent Sullivan a sketch of the plot of The Mikado. Gilbert eventually found a place for his "lozenge plot" in The Mountebanks, written with Alfred Cellier in 1892. It would take another ten months for The Mikado to reach the stage. A revised version of their 1877 work, The Sorcerer, coupled with their one-act Trial by Jury (1875), played at the Savoy while Carte and their audiences awaited their next work.
In 1914, Cellier and Bridgeman first recorded the familiar story of how Gilbert found his inspiration: “Gilbert, having determined to leave his own country alone for a while, sought elsewhere for a subject suitable to his peculiar humour. A trifling accident inspired him with an idea. One day an old Japanese sword that, for years, had been hanging on the wall of his study, fell from its place. This incident directed his attention to Japan. Just at that time a company of Japanese had arrived in England and set up a little village of their own in Knightsbridge.”
The story is an appealing one, but it is largely fictional. Gilbert was interviewed twice about his inspiration for The Mikado. In both interviews the sword was mentioned, and in one of them he said it was the inspiration for the opera, although he never said that the sword had fallen. What puts the entire story in doubt, moreover, is Cellier and Bridgeman's error concerning the Japanese exhibition in Knightsbridge: It did not open until 10 January 1885, almost two months after Gilbert had already completed Act I. Gilbert scholar Brian Jones, in his article "The Sword that Never Fell", notes that "the further removed in time the writer is from the incident, the more graphically it is recalled." Leslie Baily, for instance, told it this way in 1952: “A day or so later Gilbert was striding up and down his library in the new house at Harrington Gardens, fuming at the impasse, when a huge Japanese sword decorating the wall fell with a clatter to the floor. Gilbert picked it up. His perambulations stopped. 'It suggested the broad idea,' as he said later. His journalistic mind, always quick to seize on topicalities, turned to a Japanese Exhibition which had recently been opened in the neighbourhood. Gilbert had seen the little Japanese men and women from the Exhibition shuffling in their exotic robes through the streets of Knightsbridge. Now he sat at his writing desk and picked up the quill pen. He began making notes in his plot-book.”
The story was dramatised in more-or-less this form in the 1999 film Topsy-Turvy. However, even though the 1885–87 Japanese exhibition in Knightsbridge had not opened when Gilbert conceived of The Mikado, European trade with Japan had increased in recent decades, and an English craze for all things Japanese had built through the 1860s and 1870s. This made the time ripe for an opera set in Japan. Gilbert told a journalist, "I cannot give you a good reason for our ... piece being laid in Japan. It ... afforded scope for picturesque treatment, scenery and costume, and I think that the idea of a chief magistrate, who is ... judge and actual executioner in one, and yet would not hurt a worm, may perhaps please the public."
In an 1885 interview with the New York Daily Tribune, Gilbert also stated that the short stature of Leonora Braham, Jessie Bond and Sybil Grey "suggested the advisability of grouping them as three Japanese school-girls" referred to in the opera as the "three little maids". He also recounted that a young Japanese lady, a tea-server from the Japanese village, came to rehearsals to coach the three little maids in some native Japanese dances. On 12 February 1885, one month before The Mikado opened, the Illustrated London News wrote about the opening of the Japanese village noting, among other things, that "the graceful, fantastic dancing featured... three little maids!" Finally, Gilbert related that he and Sullivan had decided to cut the Mikado's Act II song, but that members of the company and others who had witnessed the dress rehearsal "came to us in a body and begged us to restore [it]".
The Mikado had the longest original run of the Savoy Operas. It also had the quickest revival: after Gilbert and Sullivan's next work, Ruddigore, closed relatively quickly, three operas were revived to fill the interregnum until The Yeomen of the Guard was ready, with The Mikado being revived just seventeen months after the first run closed. On 4 September 1891, D'Oyly Carte's touring "C" company gave a Royal Command Performance of The Mikado at Balmoral Castle before Queen Victoria and the Royal Family.
It was revived again while The Grand Duke was in preparation. When it became clear that that opera was not a success, The Mikado was given at matinees, and the revival continued when The Grand Duke closed after just three months. In 1906–07, Helen Carte, the widow of Richard D'Oyly Carte, mounted a repertory season at the Savoy, but The Mikado was not performed, as it was thought that visiting Japanese royalty might be offended by it. However, it was included in Mrs. Carte's second repertory season, in 1908–09. New costume designs were created by Charles Ricketts for the 1926 season and were used until 1982.
The first provincial production of The Mikado opened on 27 July 1885 in Brighton, with several members of that company leaving in August to present the first authorised American production in New York. From then on, The Mikado was a constant presence on tour. From 1885 until the Company's closure in 1982, there was no year in which a D'Oyly Carte company (or several of them) was not presenting it.
In America, as had happened with H.M.S. Pinafore, the first productions were piracies, but once the authorised American production opened in August 1885, it was a success, earning record profits, and Carte formed several companies to tour the show in North America. Burlesque and parody productions, including political parodies, were mounted. About 150 unauthorised versions cropped up, and, as had been the case with Pinafore, there was nothing that Carte or Gilbert and Sullivan could do about it, since there was no copyright treaty at the time. In Australia, The Mikado's first authorised performance was on 14 November 1885 at the Theatre Royal, Sydney, produced by J. C. Williamson. During 1886, Carte was touring five Mikado companies in North America.
Carte toured the opera in 1886 and again in 1887 in Germany and elsewhere in Europe. In September 1886, Vienna's leading critic, Eduard Hanslick, wrote that the opera's "unparalleled success" was attributable not merely to the libretto and the music, but also to "the wholly original stage performance, unique of its kind, by Mr D'Oyly Carte's artists... riveting the eye and ear with its exotic allurement." Authorised productions were also seen in France, Holland, Hungary, Spain, Belgium, Scandinavia, Russia and elsewhere.
After the Gilbert copyrights expired in 1962, the Sadler's Wells Opera mounted the first non-D'Oyly Carte professional production in England, with Clive Revill as Ko-Ko. Among the many professional revivals since then was an English National Opera production in 1986, with Eric Idle as Ko-Ko and Lesley Garrett as Yum-Yum, directed by Jonathan Miller. This production, which has been revived several times, was set not in ancient Japan, but in a swanky 1920s seaside hotel with sets and costumes in white and black.