Local officials say the frightened toddler was rescued after residents of the town of Cabezo de Torres, in south eastern Spain, were alarmed by sobbing sounds coming from a refuse skip.
After removing several plastic bags of rubbish, they found the girl inside "crying, sweating and with panic showing in her face."
It is not known how long the little girl had been in the container. Police have not named the child's parents.
Her parents have been detained and are now awaiting trial on suspicion of neglect.