Turning the tables
It originated with the playing of board games in the 17th century, according to the Oxford English Dictionary. It means “to reverse one's position relative to someone else,” the OED says, especially “by turning a position of disadvantage into one of advantage; to cause a complete reversal of the state of affairs.”
Brings to mind that amous chess game where a losing poition was turned into a winning one.