Diabetic nephropathy (DN) is a common systemic microvascular complication of diabetes with a high incidence rate. Notably, the disturbance of lipid metabolism is associated with DN progression. The present study aimed to identify lipid metabolism-related hub genes associated with DN for improved diagnosis of DN. The gene expression profile data of DN and healthy samples (GSE142153) were obtained from the Gene Expression Omnibus database, and the lipid metabolism-related genes were obtained from the Molecular Signatures Database. Differentially expressed genes (DEGs) between DN and healthy samples were analyzed. The weighted gene co-expression network analysis (WGCNA) was performed to examine the relationship between genes and clinical traits to identify the key module genes associated with DN. Next, the Venn Diagram R package was used to identify the lipid metabolism-related genes associated with DN and their protein-protein interaction (PPI) network was constructed. Subsequently, Gene Ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) enrichment analyses were performed. The hub genes were identified using machine-learning algorithms. The Gene Set Enrichment Analysis (GSEA) was used to analyze the functions of the hub genes. The present study also investigated the immune infiltration discrepancies between DN and healthy samples, and assessed the correlation between the immune cells and hub genes. Finally, the expression levels of key genes were verified by reverse transcription-quantitative (RT-q)PCR. The present study determined 1,445 DEGs in DN samples. In addition, 694 DN-related genes in MEyellow and MEturquoise modules were identified by WGCNA. Next, the Venn Diagram R package was used to identify 17 lipid metabolism-related genes and to construct a PPI network. GO analysis revealed that these 17 genes were markedly associated with 'phospholipid biosynthetic process' and 'cholesterol biosynthetic process', while the KEGG analysis showed that they were enriched in 'glycerophospholipid metabolism' and 'fatty acid degradation'. In addition, SAMD8 and CYP51A1 were identified through the intersections of two machine-learning algorithms. The results of GSEA revealed that the 'mitochondrial matrix' and 'GTPase activity' were the markedly enriched GO terms in both SAMD8 and CYP51A1. Their KEGG pathways were mainly concentrated in the 'pathways of neurodegeneration-multiple diseases'. Immune infiltration analysis showed that nine types of immune cells had different expression levels in DN (diseased) and healthy samples. Notably, SAMD8 and CYP51A1 were both markedly associated with activated B cells and effector memory CD8 T cells. Finally, RT-qPCR confirmed the high expression of SAMD8 and CYP51A1 in DN. In conclusion, lipid metabolism-related genes SAMD8 and CYP51A1 may play key roles in DN. The present study provides fundamental information on lipid metabolism that may aid the diagnosis and treatment of DN.