We have analyzed the optical (U BV) and ultraviolet (λ1000–2700 A) observations of the nuclear variability of the Seyfert galaxy NGC 4151 in the period 1987–2001 (the second cycle of activity). The fast (tens of days) and slow (∼10 years) components of the nuclear variability, F and S, respectively, are shown to be completely different, but thermal in nature. We associate the S component with the formation and evolution of an accretion disk and the F component (flares) with instabilities in the accretion disk and their propagation over the disk in the form of a shock wave. The S component is present not only in the optical, but also in the ultraviolet range, with its amplitude being comparable over the entire range λ1000–5500 A under study. The amplitude of the average flare (the F component) doubles as the wavelength decreases from 5500 to 1000 A, while the rise time of the brightness to its maximum Δt (the variability time scale) decreases from Open image in new window to 6d ± 2d. The brightness decline (flare decay) time decreases by a factor of 16. The extinction in the ultraviolet is shown to have been grossly underestimated: beginning from the first IUE data, only the extinction in our Galaxy, Open image in new window , has been taken into account. A proper allowance for the total extinction, i.e., for the extinction in the nucleus of NGC 4151 as well Open image in new window leads to a large increase in the luminosity of the variable source in the nucleus of NGC 4151: L = (6–8) × 1046 erg s−1. The spectral energy distribution for the variable source (λ950–5500 A) agrees well with two Planck distributions: Te = 65 000 (λmax = 450 A) and 8000 K. The radiation with Te = 8000 K is the reprocessing of the bulk of the ultraviolet radiation by the accretion disk with a lag of 0.5–0.6 days in the V band. The lag in the U-B variability of the slow component revealed the existence of an extended broad line region (EBLR) at an effective distance of 1.5 lt-years, as confirmed by spectroscopic data obtained at the Crimean Astrophysical Observatory. This yields the following mass of the central object in NGC 4151: Mc = (1–3) × 109M⊙. The luminosity of the variable source then accounts for 50–60% of LEdd rather than 1–2%, as has been thought previously. In general, the pattern of ultraviolet and optical variability in NGC 4151 agrees excellently with the theory of disk accretion instability for a supermassive black hole suggested by N. Shakura and R. Sunyaev 30 years ago: the energy release is at a maximumin the ultraviolet (in the case under consideration, at λ450 A), the luminosity is ∼1047 erg s−1 for Mc ∼ 109M⊙ (several tens of percent of LEdd), and the variability time scale ranges from several days to many years.