The diagnosis of mechanical faults under unknown operating conditions has been extensively investigated. In real industrial scenarios, fault diagnosis often faces challenges such as class imbalance, scarcity of class labels, and domain shifts. Existing methods cannot simultaneously address these issues. Therefore, this study proposes an imbalanced semi-supervised domain generalization-based fault diagnosis (ISDGFD) learning paradigm and develops a two-stage learning framework to tackle these issues. In the first stage, labeled data is preprocessed to address class imbalance, key features are extracted using a multi-scale convolutional neural network with a self-attention mechanism, and domain-invariant and class-aware features are initially learned through multi-domain adversarial learning and supervised learning, respectively. In the second stage, reliable pseudo-labeled samples are selected and a weighted pseudo-labeled loss is used to retrain the model, further enhancing generalization capability. Extensive experiments were conducted on the CWRU and HUST datasets. The proposed method achieved average scores of 0.85 in Recall, 0.87 in F-score, and 0.92 in Accuracy on the CWRU dataset, and 0.8052 in Recall, 0.7747 in F-score, and 0.8398 in Accuracy on the HUST dataset. These results outperform those of existing state-of-the-art semi-supervised Domain Generalization-based Fault Diagnosis (DGFD) methods and are comparable to the results of fully-supervised imbalanced DGFD methods, demonstrating its effectiveness for ISDGFD under unknown operating conditions.