Fish, as top predators in aquatic ecosystems, play an important role in maintaining the structure and functioning of these ecosystems, making their diversity a topic of great interest. This study focused on the Yangtze River Basin to investigate the fish community structure and diversity using environmental DNA (eDNA) technology. The results showed that a total of 71616 fish operational taxonomic units (OTUs) and 90 fish belonging to 23 families were detected, with the Cyprinidae family being the dominant group, followed by the Cobitidae, Amblycipitidae, etc. Compared to historical traditional morphological fish surveys, the quantity of fish detected using eDNA was relatively low, but the overall distribution pattern of fish communities was generally consistent. The highest fish Shannon-Wiener diversity index in the Yangtze River Basin sites reaches 2.60 with an average value of 1.25. The fish diversity index was higher in the downstream compared to the middle and upstream regions, and there were significant differences among different sampling sites. Significant environmental factors influencing α-diversity included chlorophyll-a, chemical oxygen demand, dissolved oxygen, total nitrogen, and elevation. Non-metric multidimensional scaling (NMDS) analysis revealed significant differences in fish community composition between the upstream and middle/lower reaches of the Yangtze River, while the composition of fish communities in the middle and lower reaches was more similar. Redundancy analysis (RDA) indicated that total organic carbon (TOC) was positively correlated with fish community distribution in the upstream, while water temperature and NO3–N were negatively correlated with fish distribution in the upstream. NH3–N and CODMn were negatively correlated with fish distribution in the middle and downstream regions, indicating a relatively severe water pollution in these areas. Additionally, fish communities in the Yangtze River displayed a typical distance decay pattern.