Direct laser writing (DLW) has been shown to render 3D polymeric optical components, including lenses, beam expanders, and mirrors, with submicrometer precision. However, these printed structures are limited to the refractive index and dispersive properties of the photopolymer. Here, we present the subsurface controllable refractive index via beam exposure (SCRIBE) method, a lithographic approach that enables the tuning of the refractive index over a range of greater than 0.3 by performing DLW inside photoresist-filled nanoporous silicon and silica scaffolds. Adjusting the laser exposure during printing enables 3D submicron control of the polymer infilling and thus the refractive index and chromatic dispersion. Combining SCRIBE's unprecedented index range and 3D writing accuracy has realized the world's smallest (15 μm diameter) spherical Luneburg lens operating at visible wavelengths. SCRIBE's ability to tune the chromatic dispersion alongside the refractive index was leveraged to render achromatic doublets in a single printing step, eliminating the need for multiple photoresins and writing sequences. SCRIBE also has the potential to form multicomponent optics by cascading optical elements within a scaffold. As a demonstration, stacked focusing structures that generate photonic nanojets were fabricated inside porous silicon. Finally, an all-pass ring resonator was coupled to a subsurface 3D waveguide. The measured quality factor of 4600 at 1550 nm suggests the possibility of compact photonic systems with optical interconnects that traverse multiple planes. SCRIBE is uniquely suited for constructing such photonic integrated circuits due to its ability to integrate multiple optical components, including lenses and waveguides, without additional printed supports.