Ensuring a secure online environment hinges on the timely detection of network attacks. Nevertheless, existing detection methods often grapple with the delicate balance between speed and accuracy. In this paper, we introduce a novel intrusion detection algorithm that marries quantum particle swarm optimization with an extreme learning machine (QPSO-ELM). Firstly, we present a feature selection algorithm grounded in partitioned gains to distill vital features from data samples, thereby diminishing feature count to amplify both model training speed and accuracy. Subsequently, we unveil an intrusion detection scheme underpinned by QPSO-ELM, capable of achieving exceptional levels of training and detection speed, all while maintaining high accuracy. Finally, we fine-tune the trained model using the proposed hidden layer node selection algorithm, reducing the detection model size without compromising detection accuracy, thus further elevating its speed. The experiment results indicate that compared to the current baseline, our proposed intrusion detection scheme achieves the best results in terms of accuracy, precision, recall, and detection latency. Furthermore, the ablation experiment results demonstrate the effectiveness of our proposed method in improving both detection speed and detection accuracy.