The ability to achieve ultrastrong coupling between light and matter promises to bring about new means to control material properties, new concepts for manipulating light at the atomic scale, and new insights into quantum electrodynamics (QED). Thus, there is a need to develop quantitative theories of QED phenomena in complex electronic and photonic systems. In this Letter, we develop a variational theory of general non-relativistic QED systems of coupled light and matter. Essential to our Ansatz is the notion of an effective photonic vacuum whose modes are different than the modes in the absence of light-matter coupling. This variational formulation leads to a set of general equations that can describe the ground state of multielectron systems coupled to many photonic modes in real space. As a first step toward a new ab initio approach to ground and excited state energies in QED, we apply our Ansatz to describe a multilevel emitter coupled to many optical modes, a system with no analytical solution. We find a compact semianalytical formula which describes ground and excited state energies very well in all regimes of coupling parameters allowed by sum rules. Our formulation provides a nonperturbative theory of Lamb shifts and Casimir-Polder forces, as well as suggest new physical concepts such as the Casimir energy of a single atom in a cavity. Our method thus give rise to highly accurate nonperturbative descriptions of many other phenomena in general QED systems.