“Sherlock Holmes and The Curious Adventure of the Clockwork Prince,” now playing at the Randall Theatre in Medford, is a Victorian romp that pays tribute to both Holmes creator Sir Arthur Conan Doyle and comedy-opera team Gilbert and Sullivan.

In this musical comedy by Cleve Haubold, Sherlock Holmes is faced with a mystifying case involving Bertram Mallow, an intelligent mechanical robot, and his missing wind-up key.

It is New Year’s Eve 1899, the end of the Victorian era, which ushered in the Industrial Revolution. As factories replaced people with machines, entrepreneurs became super rich.

The play takes place in the elegant drawing room of Sir Gilbert Mallow, “The Marshmallow King.” Preparations are being made for a birthday party and a grand celebration of the turn of the century. There are servants galore, including a bevy of maids dusting and singing: “‘Tis a time for merry song, For feasting and enjoyment. We’ll be festive as we’re told, to keep in our employment!”

Sir Gilbert tells Bertram, his son and heir, how he built his financial kingdom from a lowly Mallow Marsh in England into plantations in Saigon and Caracas, packaging plants in London and Paris and worldwide shops for distribution, all upon the solid foundation of marshmallows.

It is young Bertram’s birthday, and in order for Bertram, “a clockwork foundling,” to stay alive, he must be wound up each year at the strike of 12. Otherwise he will run down, becoming “stiff as a mackerel.” Sir Gilbert predicts his worst fate, “We might find some use for him as a hall-tree or a paper-weight if he expires in a suitable posture … but … I had higher plans for his future.”

Something is awry. The brass wind-up key has been stolen, along with a valuable secret formula for licorice marshmallows. There is a ransom note and a prime suspect: a former actor, gone bad, and a master of disguise, Sir Sullivan Sinister.

Although she is tippling, deaf and doddering, the cook, Mrs. Alan, is dispatched to fetch Sherlock Holmes. She goes missing, only to be replaced by several impostors.

There are figures in black hooded capes, and characters in not so “impenetrable” disguises. Sherlock’s favorite, a Cantonese Salad Chef disguise, is replaced by a bright blazing red full beard and dark glasses, which is donned by several characters. Many jump in and out of the grandfather clock, in and out of their various disguises. And young Bertram, now turning 21, is disappointed not to be able to wear his red fireman suit, which he got for his last birthday.

Robin Downward’s Sherlock Holmes is comically confused and bewildered as events unfold, but he is still conscious of his expertise. He boasts, “I may disguise myself as several people … not, however, simultaneously. Some few things are beyond even my talents.” He croons: “I look for clues on dead men’s shoes. I must have found a million. I even found a haunting hound, who turned out Baskervillian!” He is also delightfully mad.

Although the production notes stipulate that the piece “should be played with the most perfect seriousness and gravity,” director Elizabeth Suzanne chose to infuse it with lots of physical comedy and buffoonery.

John Oles plays Watson as a bumbling teddy bear. Michael Williams as Sir Gilbert lurches around the stage, while Brad Zentgraf as Bertram operates as smoothly as an electric clock, punctuated with sounds of an alarm clock, Big Ben and various chimes. Erny Rosales makes a comely Miss Lucy, so sweetly in love. And after much mayhem and swordplay, there is a surprise discovery scene befitting the delightful Mrs. Alan, Becky Durango. True to form, Holmes defeats his nemesis, Sir Sullivan Sinister (Nick Walker), by recognizing Sinister’s passion for logical symmetry and bad puns.

The robust and enthusiastic cast carries the plot at breakneck speed to its suspenseful conclusion. As the distinguished gentleman sitting next to me said, “It’s farcical. But every once in a while, you need a good farce.”

Advance tickets are available online at www.randalltheatre.com or by calling 541-632-3258. Performances continue at 7 p.m. Thursdays through Saturdays, Feb. 16-18 and Feb. 23-25. Matinees are at 1 p.m. Sundays, Feb. 19 and 26.

Evalyn Hansen is a freelance writer based in Ashland. Reach her at evalyn_robinson@yahoo.com.