To pull the rabbit out of the hat means to do something surpising and unexpected.
A favourite trick of magicians is to produce a rabbit out of a top hat.
Examples of use:
a) Tennis player Andy Murray might pull the rabbit out of the hat this summer and win Wimbledon.
b) She pulled the rabbit out of the hat and passed her exams!
c) He pulled the rabbit out of the hat in the second half of the semi-final and scored a goal.
d) News headline: Can Gordon Brown pull a rabbit out of the hat and win next year's election?
Image © Angela Boothroyd.