Precise prediction of hospital stay duration is essential for maximizing resource utilization during surgery. Existing lumbar spinal stenosis (LSS) surgery prediction models lack accuracy and generalizability. Machine learning can improve accuracy by considering preoperative factors. This study aimed to develop and validate a machine learning-based model for estimating hospital stay duration following decompression surgery for LSS. Data from 848 patients who underwent decompression surgery for LSS at three hospitals were examined. Twelve prediction models, using 79 preoperative variables, were developed for postoperative hospital stay estimation. The top five models were chosen. Fourteen models predicted prolonged hospital stay (≥14 days), and the most accurate model was chosen. Models were validated using a randomly divided training sample (70%) and testing cohort (30%). The top five models showed moderate linear correlations (0.576-0.624) between predicted and measured values in the testing sample. The ensemble of these models had moderate prediction accuracy for final length of stay (linear correlation 0.626, absolute mean error 2.26 days, standard deviation 3.45 days). The c5.0 decision tree model was the top predictor for prolonged hospital stay, with accuracies of 89.63% (training) and 87.2% (testing). Key predictors for longer stay included JOABPEQ social life domain, facility, history of vertebral fracture, diagnosis, and Visual Analogue Scale (VAS) of low back pain. A machine learning-based model was developed to predict postoperative hospital stay after LSS decompression surgery, using data from multiple hospital settings. Numerical prediction of length of stay was not very accurate, although favorable prediction of prolonged stay was accomplished using preoperative factors. The JOABPEQ social life domain score was the most important predictor.