Firefly algorithm (FA) combined with extreme learning machine (ELM) is developed for spectral interval selection and quantitative analysis of complex samples. The method firstly segments the spectra into a certain number of intervals. Vectors with 1 and 0, which represent the interval selected or not, are used as the inputs of the FA. The RMSEP value predicted by ELM model is used as the fitness function of the FA. The activation function and number of hidden layer nodes of ELM, number of spectral intervals, population number, environmental absorbance, and constant of FA are optimized. The predictive performance of FA‐ELM is compared with full‐spectrum PLS, ELM, genetic algorithm‐ELM (GA‐ELM), and particle swarm optimization‐ELM (PSO‐ELM) by one ultraviolet (UV) spectrum dataset of gasoil and three near‐infrared (NIR) spectral datasets of corn, wheat, and tablet samples. The results show that FA‐ELM has a better performance compared with its competitors in predicting monoaromatics, water, wheat kernel texture, and active pharmaceutical ingredients (APIs) in gasoil, corn, wheat, and tablet samples.