Verb
pull a rabbit out of a hat (third-person singular simple present pulls a rabbit out of a hat, present participle pulling a rabbit out of a hat, simple past and past participle pulled a rabbit out of a hat)
(idiomatic) To do something surprising and beneficial that is unexpected.