Two-dimensional black phosphorus (BP) generally exhibits a hole-dominated transport characteristic when configured as field-effect transistor devices. The effective control of charge carrier type and concentration is very crucial for the application of BP in complementary electronics. Herein, we report a facile and effective electron doping methodology on BP, through in situ surface modification with aluminum (Al). The electron mobility of few-layer BP is found to be largely enhanced to ~ 10.6 cm2·V-1·s-1 by over 6 times after aluminum modification. In situ photoelectron spectroscopy characterization reveals the formation of Al-P covalent bond at the interface, which can also serve as local gate to tune the transport properties in BP layers. Finally, a spatially-controlled aluminum doping technique is employed to establish a p-n homojunction on a single BP flake, and hence to realize the complementary inverter devices, where the highest gain value of ~ 33 is obtained.