It is a nice approach in the short term, but in the long run you will pay with interest as the AI, who was trying to get the city before will try to get it afterwards too, so you may expect they will besiege you there everytime they will gather an army to do so from this moment all the way until they force you to wipe them out just to get rid of their constant attacks.

Do not curse the stupid AI, curse your own greed and betrayal of allies!