When the tables are turned means the situation has changed giving the advantage to the party who had previously been at a disadvantage.
To turn the tables also means that the situation has changed or a major change has happened.
The tables are turned or when the tables are turned originated in the 17th century.
Until the medieval 18th century, tables was usually used for the board game backgammon.
This phrase the tables are turned was earlier used during mid 17th century, making it significant that it originates from the practice of turning the board so that a player would play at the position that was previously that of their competitor.
Some example sentences of the tables are turned are.
I should have known she is smart enough to turn the tables.
The businessman who was on the verge of bankruptcy turned the tables when he won a million dollar in casino with a few thousands he had.
The activist held a seminar for people to turn the tables in government employees who ask for bribery.