A new prognostic, spatially and temporally dependent variable is introduced to the Weather Research and Forecasting Model (WRF). This variable is called the potential electrical energy (Ep). It was used to predict the dynamic contribution of the grid-scale-resolved microphysical and vertical velocity fields to the production of cloud-to-ground and intracloud lightning in convection-allowing forecasts. The source of Ep is assumed to be the noninductive charge separation process involving collisions of graupel and ice particles in the presence of supercooled liquid water. The Ep dissipates when it exceeds preassigned threshold values and lightning is generated. An analysis of four case studies is presented and analyzed. On the 4-km simulation grid, a single cloud-to-ground lightning event was forecast with about equal values of probability of detection (POD) and false alarm ratio (FAR). However, when lighting was integrated onto 12-km and then 36-km grid overlays, there was a large improvement in the forecast skill, and as many as 10 cloud-to-ground lighting events were well forecast on the 36-km grid. The impact of initial conditions on forecast accuracy is briefly discussed, including an evaluation of the scheme in wintertime, when lightning activity is weaker. The dynamic algorithm forecasts are also contrasted with statistical lightning forecasts and differences are noted. The scheme is being used operationally with the Rapid Refresh (13 km) data; the skill scores in these operational runs were very good in clearly defined convective situations.