In this paper, we propose a novel numerical method for modeling nanostructures containing dispersive and nonlinear two-dimensional (2D) materials, by incorporating a nonlinear generalized source (GS) into the finite-difference time-domain (FDTD) method. Starting from the expressions of nonlinear currents characterizing nonlinear processes in 2D materials, such as second-and thirdharmonic generation, we prove that the nonlinear response of such nanostructures can be rigorously determined using two linear simulations. In the first simulation, one computes the linear response of the system upon its excitation by a pulsed incoming wave, whereas in the second one the system is excited by a nonlinear generalized source, which is determined by the linear near-field calculated in the first linear simulation. This new method is particularly suitable for the analysis of dispersive and nonlinear 2D materials, such as graphene and transition-metal dichalcogenides, chiefly because, unlike the case of most alternative approaches, it does not require the thickness of the 2D material. In order to investigate the accuracy of the proposed GS-FDTD method and illustrate its versatility, the linear and nonlinear response of graphene gratings have been calculated and compared to results obtained using alternative methods. Importantly, the proposed GS-FDTD can be extended to 3D bulk nonlinearities, rendering it a powerful tool for the design and analysis of more complicated nanodevices.