Transport of K+ by the lower, main and distal segments of the Malpighian tubules of Drosophila melanogaster was analyzed using self-referencing K+-selective microelectrodes. Transport properties of the Malpighian tubules of Drosophila melanogaster change along their length. Self-referencing ion-selective (SeRIS) microelectrode measurements (relative to the bath concentration of 20 mmoll−1) showed a 1% reduction (P<0.05) of [K+] in the unstirred layer adjacent to the main segment of the Malpighian tubules, confirming secretion of K+ from the bath to the tubule lumen. Conversely, SeRIS measurements showed a 0.7% increase (P<0.05) in [K+] in the unstirred layer adjacent to the lower segment of Malpighian tubules, confirming reabsorption of K+ from the luminal fluid to the bath. Measurements using SeRIS also showed that the distal segment neither secreted nor reabsorbed K+. There was pronounced spatial heterogeneity in K+ transport by the lower segment and the main segment; not all morphologically similar cells participated equally in K+ transport, nor did all main segment cells respond equally to stimulation of K+ transport by cyclic AMP. Pronounced temporal heterogeneity in K+ reabsorption by the lower Malpighian tubules was also observed. We suggest that this reflects periodic reduction in K+ reabsorption due to retention of fluid within the lower segment when the ureter contracts.