pull something/a rabbit out of the hat

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