Power quality disturbances (PQDs) can lead to significant operational and financial losses in power systems. Accurate detection and classification of PQDs are essential for maintaining power quality and preventing power system failures. This research article introduces an innovative approach for the precise detection and classification of single- and multiple-state power quality disturbances (PQDs) using the Stockwell transform (ST) and a random forest classifier. To create realistic PQD signals, seventeen distinct classes are generated in accordance with IEEE Standard 1159, employing mathematical equations implemented in MATLAB software. The ST is employed to extract relevant features from the PQD signals, which are subsequently utilized as input for the random forest classifier. The classifier employs bootstrapping sampling to generate multiple training sets from the original dataset. Each training set is used to construct a decision tree by recursively partitioning the data based on significant features. To mitigate overfitting and enhance robustness, a random subset of features is selected at each node of the decision tree, thereby reducing tree correlation. The performance of the random forest classifier is compared with other widely utilized machine learning classifiers. The results exhibit the efficacy of the proposed approach in accurately detecting and classifying PQ events, highlighting its superiority over alternative methods.