pull a rabbit out of a 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 magician's trick of literally pulling a live rabbit out of a hat. The caterer really pulled a rabbit out of a hat by producing 100 cupcakes with just 20 minutes' notice. Unless someone can pull a rabbit out of a hat, we're out of solutions.
pull a rabbit out of a hat, to
To come up with a surprise, usually a pleasant one. The term comes from the magician’s trick of pulling a live rabbit out of a seemingly empty hat. While the trick is old, the term was being transferred to other surprises only from the 1930s on. D. Sannon used it in Death by Inches (1965): “Well, you pulled the rabbit out of the hat.”