The Madtsoiidae were medium sized to gigantic snakes with a fossil record extending from the mid-Cretaceous to the Pleistocene, and spanning Europe, Africa, Madagascar, South America and Australia. This widely distributed group survived for about 90 million years (70% of known ophidian history), and potentially provides important insights into the origin and early evolution of snakes. However, madtsoiids are known mostly from their vertebrae, and their skull morphology and phylogenetic affinities have been enigmatic. Here we report new Australian material of Wonambi, one of the last-surviving madtsoiids, that allows the first detailed assessment of madtsoiid cranial anatomy and relationships. Despite its recent age, which could have overlapped with human history in Australia, Wonambi is one of the most primitive snakes known--as basal as the Cretaceous forms Pachyrhachis and Dinilysia. None of these three primitive snake lineages shows features associated with burrowing, nor do any of the nearest lizard relatives of snakes (varanoids). These phylogenetic conclusions contradict the widely held 'subterranean' theory of snake origins, and instead imply that burrowing snakes (scolecophidians and anilioids) acquired their fossorial adaptations after the evolution of the snake body form and jaw apparatus in a large aquatic or (surface-active) terrestrial ancestor.