In this paper, a nonlinear adaptive backstepping controller is designed to control the common dc-bus voltage for different components in a dc microgrid under various operating conditions. The dc microgrid in this paper comprises a solar photovoltaic (PV) unit, a battery energy storage system (BESS), a backup diesel generator, and loads (both critical and noncritical). The controllers are designed for all components except loads where the main control objective for all controllers is to maintain a constant voltage at the dc-bus where all components are connected. This paper considers solar PV systems as the renewable energy source, whereas a diesel generator equipped with a rectifier is used as a backup supply to maintain the continuity of power supply in the case of emergency situations. The proposed controller is designed recursively based on the Lyapunov control theory, where all parameters within the model of different components are considered unknown. Adaptation laws are used to estimate these unknown parameters while the stability of the dc microgrid, with these adaptation laws, is ensured through the formulation of suitable control Lyapunov functions (CLFs) at different stages of the design process. The negative definiteness or semidefiniteness of these CLFs guarantees the stability of the dc microgrid. Finally, the performance of the proposed controllers is verified using both simulations and experiments on a test dc microgrid under different operating conditions. The proposed controller ensures the regulation of the dc-bus voltage within the acceptable limits under different operating conditions.