Wiktionary
pull a rabbit out of a hat
vb. (label en idiomatic) To do something surprising or beneficial.