By fighting the Ottoman Empire and their protectorate -- the remains of the Golden Horde known as Crimean Khanate [0]. The last was busy raiding Russia and selling captured slaves to Ottomans [1]. The Golden Horde, in case you don't know, is itself one the remains of the Mongol Empire.
"What happened to its original inhabitants?"
Scythians [2] and Tauri [3] were assimilated by Sarmatians and later were partly destroyed and party assimilated by Goths. Why did you ask?
"Which treaty"
It looks like you are asking in bad faith and already know the answer. When circumstances change treaties become obsolete. Ever heard of Anti-Ballistic Missile Treaty, for example? [4]
[0] https://en.wikipedia.org/wiki/Annexation_of_the_Crimean_Khan...
[1] https://en.wikipedia.org/wiki/Crimean%E2%80%93Nogai_slave_ra...
[2] https://en.wikipedia.org/wiki/Scythia_Minor_(Crimea)
[3] https://en.wikipedia.org/wiki/Tauri
[4] https://en.wikipedia.org/wiki/Anti-Ballistic_Missile_Treaty