Molecular docking is an essential computational tool in structure-based drug discovery and the investigation of the molecular mechanisms underlying biological processes. Despite the development of many molecular docking programs for various systems, a universal tool that can accurately dock ligands across multiple system types remains elusive. Meeting the need, we developed XDock, a versatile docking framework built for both protein-ligand and nucleic acid-ligand interactions. XDock efficiently accounts for ligand flexibility by docking multiple conformations of a ligand and flexibly refining the final binding poses. It utilizes a distance geometric method for ligand sampling and leverages our knowledge-based scoring functions for assessing protein-ligand and nucleic acid-ligand interactions. XDock has undergone extensive validations on diverse benchmarks of protein-ligand and nucleic acid-ligand complexes and was compared with six other docking methods, including DOCK 6, AutoDock Vina, PLANTS, LeDock, rDock, and RLDock. In addition, XDock is also computationally efficient and on average can dock a ligand within 1 min.