The topic of density-driven convection in porous media has been the focus of many recent studies due to its relevance as a long-term trapping mechanism during geological sequestration of carbon dioxide. Most of these studies have addressed the problem in homogeneous and anisotropic permeability fields using linear-stability analysis, and relatively little attention has been paid to the analysis for heterogeneous systems. Previous investigators have reduced the governing equations to an initial-value problem and have analysed it either with a quasi-steady-state approximation model or using numerical integration with arbitrary initial perturbations. Recently, Rapaka et al. (J. Fluid Mech., vol. 609, 2008, pp. 285–303) used the idea of non-modal stability analysis to compute the maximum amplification of perturbations in this system, optimized over the entire space of initial perturbations. This technique is a mathematically rigorous extension of the traditional normal-mode analysis to non-normal and time-dependent problems. In this work, we extend this analysis to the important cases of anisotropic and layered porous media with a permeability variation in the vertical direction. The governing equations are linearized and reduced to a set of coupled ordinary differential equations of the initial-value type using the Galerkin technique. Non-modal stability analysis is used to compute the maximum growth of perturbations along with the optimal wavenumber leading to this growth. We show that unlike the solution of the initial-value problem, results obtained using non-modal analysis are insensitive to the choice of bottom boundary condition. For the anisotropic problem, the dependence of critical time and wavenumber on the anisotropy ratio was found to be in good agreement with theoretical scalings proposed by Ennis-King et al. (Phys. Fluids, vol. 17, 2005, paper no. 084107). For heterogeneous systems, we show that uncertainty in the permeability field at low wavenumbers can influence the growth of perturbations. We use a Monte Carlo approach to compute the mean and standard deviation of the critical time for a sample permeability field. The results from theory are also compared with finite-volume simulations of the governing equations using fully heterogeneous porous media with strong layering. We show that the results from non-modal stability analysis match extremely well with those obtained from the simulations as long as the assumption of strong layering remains valid.