Functionalization of atomically thin nanomaterials enables the tailoring of their chemical, optical and electronic properties. Exfoliated black phosphorus (BP)-a layered two-dimensional semiconductor-exhibits favourable charge-carrier mobility, tunable bandgap and highly anisotropic properties, but it is chemically reactive and degrades rapidly in ambient conditions. Here we show that covalent aryl diazonium functionalization suppresses the chemical degradation of exfoliated BP even after three weeks of ambient exposure. This chemical modification scheme spontaneously forms phosphorus-carbon bonds, has a reaction rate sensitive to the aryl diazonium substituent and alters the electronic properties of exfoliated BP, ultimately yielding a strong, tunable p-type doping that simultaneously improves the field-effect transistor mobility and on/off current ratio. This chemical functionalization pathway controllably modifies the properties of exfoliated BP, and thus improves its prospects for nanoelectronic applications.