Conventional drilling parameter optimization, heavily reliant on lagging lithology data from periodic mud logging, suffers from significant delays between formation change detection and parameter adjustment. This latency often leads to reduced Rate of Penetration (ROP), accelerated tool wear, and increased risk of drilling complications. To address this, this work introduces a closed-loop machine learning framework for real-time lithology identification and autonomous parameter optimization. Its core is a hybrid deep learning model (1D-CNN-LSTM) that establishes a direct mapping from surface drilling parameters, Weight on Bit (WOB), Rotary Speed (RPM), Torque, ROP, to formation lithology, deliberately excluding dependency on expensive Logging-While-Drilling (LWD) tools to ensure cost-effective and broad applicability. Upon lithology change detection, the system retrieves the historically optimal Mechanical Specific Energy (MSE) value for the identified rock type and solves an inverse MSE model to compute optimal WOB and RPM setpoints within operational constraints. Field validation in a comparative trial demonstrated the framework’s efficacy: the test well achieved a 17.4% increase in ROP, a 37.8% reduction in Non-Productive Time, and an 87.5% decrease in stuck pipe incidents compared to an offset well drilled conventionally.