Photolithography is an important manufacturing process that relies on using photoresists, typically polymer formulations, that change solubility when illuminated with ultraviolet light. Here, we introduce a general chemical approach for photoresist-free, direct optical lithography of functional inorganic nanomaterials. The patterned materials can be metals, semiconductors, oxides, magnetic, or rare earth compositions. No organic impurities are present in the patterned layers, which helps achieve good electronic and optical properties. The conductivity, carrier mobility, dielectric, and luminescence properties of optically patterned layers are on par with the properties of state-of-the-art solution-processed materials. The ability to directly pattern all-inorganic layers by using a light exposure dose comparable with that of organic photoresists provides an alternate route for thin-film device manufacturing.