The duke and duchess of Cambridge, along with Prince Harry were at the Warner Bros. Studios, Leavesden, outside London for the inauguration of its $155 million makeover.
The studio is on the site of a former World War II airdrome and is one of the few places in Britain where large-scale productions can be made.
The three royals were taken through parts of the studios' Hogwart's School and given a lesson in how to cast spells.
The sets they were shown included the Great Hall, Dumbledore's office and Hagrid's hut. They also met "Potter" author J.K. Rowling.
In front of the set for the Gryffindor Common Room, one of the four houses at Hogwarts School of Witchcraft and Wizardry, the duke and duchess were given a wand lesson, British newspaper The Daily Telegraph reported.
William was given a replica of Harry Potter's wand and Kate received a copy of the wand used by Harry Potter friend Hermione Granger.
The royal couple were taught three different wand movements before being invited to duel each other.
When the duel began, William quickly yelled, "Expelliarmus!" -- a spell used in the story to disarm another wizard, typically causing the victim's wand to fly out of reach -- but Kate retained her sword, nonetheless.
William, 30, then used all three moves he learned against 31-year-old Kate, who is six months pregnant, and then declared, "I win!"
Harry, 28, later grabbed a wand and tried the patronus charm to fend off soulless dementors, but his "Expecto patronum!" failed to produce even a flimsy magical shield, the Telegraph said.
The royals earlier saw props and costumes from director-writer Christopher Nolan's "Dark Knight" Batman trilogy.
William, a motorcyclist, sat astride Batman's Batpod motorcycle, saying, "Where's the start button?"
William then sat inside the Batmobile, starting up its 5.7-liter engine and revving it loudly. Harry stuck his fingers in his ears, the Telegraph said.
"I'm a very happy man," William said as he emerged.
Later, in a speech to Warner Bros. executives, William, whose baby is due in July, asked, "You don't do baby seats for those cars, do you?"
He added: "Please make another in the 'Dark Knight' series. And another, and another."