Accurate origin–destination (OD) demand prediction is crucial for the efficient operation and management of urban rail transit (URT) systems, particularly during a pandemic. However, this task faces several limitations, including real-time availability, sparsity, and high-dimensionality issues, and the impact of the pandemic. Consequently, this study proposes a unified framework called the physics-guided adaptive graph spatial–temporal attention network (PAG-STAN) for metro OD demand prediction under pandemic conditions. Specifically, PAG-STAN introduces a real-time OD estimation module to estimate real-time complete OD demand matrices. Subsequently, a novel dynamic OD demand matrix compression module is proposed to generate dense real-time OD demand matrices. Thereafter, PAG-STAN leverages various heterogeneous data to learn the evolutionary trend of future OD ridership during the pandemic. Finally, a masked physics-guided loss function (MPG-loss function) incorporates the physical quantity information between the OD demand and inbound flow into the loss function to enhance model interpretability. PAG-STAN demonstrated favorable performance on two real-world metro OD demand datasets under the pandemic and conventional scenarios, highlighting its robustness and sensitivity for metro OD demand prediction. A series of ablation studies were conducted to verify the indispensability of each module in PAG-STAN.