Skin cancer is one of the most common types of cancer globally. Despite the remarkable advancements of deep learning methods in computer vision, automatic diagnosis of skin diseases still faces challenges such as limited data and class imbalance. Generative Adversarial Networks (GANs), which can synthesize realistic data, appear as an alternative to mitigate these issues. However, for imbalanced data, unconditional GANs either generate uneven data distribution or neglect universal knowledge of the whole dataset, while state-of-the-art (SOTA) conditional GANs suffer from performance degradation due to the mode collapse of minority classes. This paper proposes a two-stage GAN-based method to synthesize finegrained and diverse 256×256 pixels skin lesion images for the imbalanced dataset, named Self-Transfer GAN (STGAN). STGAN first learns universal knowledge from all classes then transfers this shared knowledge to each class and fuses it with class-specific knowledge to synthesize high-quality images. Furthermore, based on STGAN, a framework to enhance the classification performance is established. Both data generation and classification tasks are evaluated on HAM10000 dataset. In terms of Fré chet Inception Distance (FID), Inception Score, Precision, and Recall, STGAN improved by 16%, 16%, 4%, 33% compared with SOTA conditional StyleGAN2. For classification, the STGAN-based framework achieves remarkable results, with an Accuracy of 98.23%, Sensitivity of 88.85%, Precision of 90.23%, F1-score of 89.48%, and Specificity of 98.34%.