The ability to control the size of the electronic bandgap is an integral part of solid-state technology. Atomically-thin two-dimensional crystals offer a new approach for tuning the energies of the electronic states based on the interplay between the environmental sensitivity and unusual strength of the Coulomb interaction in these materials. By engineering the surrounding dielectric environment, we are able to tune the electronic bandgap in monolayers of WS2 and WSe2 by hundreds of meV. We exploit this behavior to present an in-plane dielectric heterostructure with a spatially dependent bandgap, illustrating the feasibility of our approach for the creation of lateral junctions with nanoscale resolution. This successful demonstration of bandgap engineering based on the non-invasive modification of the Coulomb interaction should enable the design of a new class of atomically thin devices to advance the limits of size and functionality for solid-state technologies.