In larvae of most Lepidoptera the distal ends of the Malpighian tubules are closely applied to the rectal epithelia and are ensheathed within the perinephric membrane, thus forming the rectal complex. The cryptonephric Malpighian tubules within the rectal complex are bathed in fluid within a functional compartment, the perinephric space, which is separate from the haemolymph. In this study, the scanning ion-selective electrode technique (SIET) was used to measure transport of Na+ and K+ across the rectal complex and across multiple regions of the Malpighian tubules of larvae of the cabbage looper Trichoplusia ni. Measurements were made in an intact preparation in which connections of the tubules upstream to the rectal complex and downstream to the urinary bladder and gut remained intact. SIET measurements revealed reabsorption of Na+ and K+ across the intact rectal complex and into the bath (haemolymph), with K+ fluxes approximately twice as large as those of Na+. Analyses of fluxes in larvae with empty guts, found in recently moulted larvae, versus those with full guts highlighted differences in the rates of K+ or Na+ transport within tubule regions that appeared morphologically homogeneous, such as the rectal lead. The distal rectal lead of larvae with empty guts reabsorbed K+, whereas the same region secreted K+ in tubules of larvae with full guts. SIET measurements of the ileac plexus also indicated a novel role for secondary (type II) cells in cation reabsorption. Secondary cells reabsorb K+, whereas the adjacent principal (type I) cells secrete K+. Na+ is reabsorbed by both principal and secondary cells, but the rate of reabsorption by the secondary cells is approximately twice the rate in the adjacent principal cells.