Gas exchange and ion regulation at gills have key roles in the evolution of vertebrates1-4. Gills are hypothesized to have first acquired these important homeostatic functions from the skin in stem vertebrates, facilitating the evolution of larger, more-active modes of life2,3,5. However, this hypothesis lacks functional support in relevant taxa. Here we characterize the function of gills and skin in a vertebrate (lamprey ammocoete; Entosphenus tridentatus), a cephalochordate (amphioxus; Branchiostoma floridae) and a hemichordate (acorn worm; Saccoglossus kowalevskii) with the presumed burrowing, filter-feeding traits of vertebrate ancestors6-9. We provide functional support for a vertebrate origin of gas exchange at the gills with increasing body size and activity, as direct measurements in vivo reveal that gills are the dominant site of gas exchange only in ammocoetes, and only with increasing body size or challenges to oxygen supply and demand. Conversely, gills of all three taxa are implicated in ion regulation. Ammocoete gills are responsible for all ion flux at all body sizes, whereas molecular markers for ion regulation are higher in the gills than in the skin of amphioxus and acorn worms. This suggests that ion regulation at gills has an earlier origin than gas exchangethat is unrelated to vertebrate size and activity-perhaps at the very inception of pharyngeal pores in stem deuterostomes.