pull a rabbit out of the hat

US /pʊl ə ˈræbɪt aʊt əv ðə hæt/
UK /pʊl ə ˈræbɪt aʊt əv ðə hæt/
"pull a rabbit out of the hat" picture
1.

to do something unexpected and surprising that solves a problem

:
The team was losing, but the coach managed to pull a rabbit out of the hat with a last-minute strategy change.
We need someone to pull a rabbit out of the hat to save this failing project.