The Tables have Turned

I’d like to know where the saying “the tables have turned” comes from.

I found one explanation regarding tables having a rough side and a regular side but it made zero sense and had no correlation between the saying’s meaning and supposed origin.

I’d guess it comes from playing chess, where a master will challenge a contender who is giving up: Turn the table around so that I have your color and I will still win from what you consider a hopeless position.

The tables have turned.