Background: This research conducts a contextual comparative analysis between Dar es Salaam and Mombasa ports, employing a hybrid data envelopment analysis (DEA) model that integrates the contextual value-added approach (CVA). The assessment incorporates various inputs (quay length, number of cranes, and storage area) and outputs (number of ship calls and cargo throughput) to compute efficiency scores, offering nuanced insights into the strengths, weaknesses, and areas for improvement of both ports. Methods: The hybrid DEA model with CVA is applied to calculate efficiency scores, considering the diverse inputs and outputs. This approach allows for a comprehensive evaluation of the relative performance of Dar es Salaam and Mombasa ports. The study also explores the influence of trade-related externalities on port efficiency, providing a holistic understanding of the factors shaping the ports’ operational effectiveness. Results: The efficiency scores depict distinctive performance trends between Dar es Salaam and Mombasa ports. Notably, Dar es Salaam exhibits maximum efficiency (efficiency value of 1) in 2018 and 2021, while Mombasa attains optimal performance (efficiency value of 1) in 2021. However, efficiency values fluctuate for both ports in other years, ranging between 0.895 and 0.985 for Mombasa and 0.924 and 0.960 for Dar es Salaam. Conclusions: This study highlights the dynamic efficiency levels of Dar es Salaam and Mombasa ports over multiple years and identifies critical factors influencing their performance. The findings contribute valuable insights to the field of port analysis, offering guidance to port management and policymakers in optimizing the efficiency and competitiveness of these vital maritime hubs.