pull something/a rabbit out of the hat

pull a rabbit out of (one's)/the hat

To do something surprising and seemingly impossible; to produce something in a way that has no obvious explanation, as if done by magic. A reference to the clichéd magician's trick of pulling a live rabbit out of a seemingly empty hat. The caterers really pulled a rabbit out of the hat by producing 100 cupcakes with just 20 minutes' notice. Unless someone can pull a rabbit out of their hat, I just don't see how we can fix the issue without starting the whole thing over again from scratch.
See also: hat, of, out, pull, rabbit
Farlex Dictionary of Idioms.

pull something/a ˌrabbit out of the ˈhat

(informal) suddenly produce something as a solution to a problem: We had almost given up hope when Mick pulled a rabbit out of the hat by coming up with a great new idea.
This is a trick that is often done by magicians.
See also: hat, of, out, pull, rabbit, something
Farlex Partner Idioms Dictionary
See also:
  • a/the feel of (something)
  • (I) wouldn't (do something) if I were you
  • a straw will show which way the wind blows
  • a crack at (someone or something)
  • all right
  • (you) wanna make something of it?
  • all for the best
  • a thing of the past
  • a slew of (something)
  • a bird in the hand