The domain shifts often hinder accurate medical image segmentation, particularly when models trained on a source dataset are applied to a heterogeneous target dataset. To address this challenge, we propose a Dual-Path Attention Network (D \(^{2}\) N) that explicitly incorporates domain adaptation. The framework integrates a Gradient Reversal Mechanism (GRM) to encourage domain-invariant feature learning, along with a Cross-Domain Attention Module (CDAM) that enhances the fusion of global contextual information and local boundary details, thereby improving segmentation accuracy. To comprehensively evaluate the proposed model, we conducted experiments across four medical imaging datasets spanning diverse clinical applications: skin cancer segmentation (ISIC2018 and PH2), polyp segmentation and brain tumor segmentation. D \(^{2}\) N achieved strong performance, with Dice scores of \(94.0\%\) on ISIC2018, \(92.1\%\) on PH2, \(96.55\%\) on the polyp dataset and \(91.5\%\) on the brain tumor dataset. When compared against existing state-of-the-art methods, D \(^{2}\) N consistently achieved better performance than competing approaches, with superior Dice, IoU and other metric scores across all datasets. These findings demonstrate that D \(^{2}\) N effectively mitigates the impact of domain shift, substantially improves segmentation precision and generalizes well across a range of imaging modalities and anatomical structures. The code is available in the GitHub repository at https://github.com/nooriahmed/D2N-Dual-Path-Attention.