Dingoes (Canis dingo) are wild canids living in Australia. They have lived isolated from both the wild and the domestic ancestor and are a unique model for studying feralization, the process in which a domestic species escapes human control, adapts to the wild, and diverges from the domestic ancestor into a genetically distinct population. Here, we sequenced the genomes of 10 dingoes and 2 New Guinea Singing Dogs, to study the origins and feralization process of the dingo. Phylogenetic and demographic analyses show that dingoes originate from domestic dogs in southern East Asia, which migrated via Island Southeast Asia to reach Australia 4300-5000 years ago, and subsequently diverged into a genetically distinct population. Selection analysis identified 99 positively selected genes enriched in starch and fat metabolism pathways, indicating a diet change during feralization of dingoes. Interestingly, we found that 14 genes have shifted allele frequencies compared to dogs but not compared to wolves. This suggests that the selection affecting these genes during domestication of the wolf was reversed in the feralization process. One of these genes, ARHGEF7, may promote the formation of neural spine and synapses in hippocampal neurons. Functional assays showed that an A to G mutation in ARHGEF7, located in a transcription factor-binding site, decreases the endogenous expression. This suggests that ARHGEF7 may have been under selection for behavioral adaptations related to the transitions in environment both from wild to domestic and from domestic back to wild. Our results indicate that adaptation to domestication and feralization primarily affected different genomic regions, but that some genes, related to neurodevelopment, metabolism and reproduction, may have been reversibly affected in the two processes.