In the "Kurma Purana", Agni creates Maya Sita who takes the place of Sita for the abduction and returns her the real "unblemished" Sita when Maya Sita enters the fire at Agni Pariksha and thus safeguards Sita's purity.
In the "Kurma Purana", Agni creates Maya Sita who takes the place of Sita before her abduction by Ravana. After Ravana's defeat, Agni returns the real "unblemished" Sita to Rama when Maya Sita enters the fire at Agni Pariksha and thus safeguards Sita's purity.