One of the main reasons for prostate cancer (PCa) recurrence is the difficulty in identifying and removing cancerous lesions during surgery. Accurately localizing and excising cancerous tissue remains a significant challenge. The second near-infrared window (NIR-II, 1000-1700nm) fluorescence offers enhanced resolution, a high signal-to-noise ratio, and the potential for deeper tissue penetration. However, this technology is not currently employed for intraoperative imaging of PCa. This study aims to construct a new NIR-II probe targeting B7-H3 (AbB7-H3-800CW) for accurate intraoperative identification and resection of PCa. Based on the differential expression of B7-H3 in PCa, we designed a novel imaging probe to accurately identify and guide the resection of preclinical PCa models and ex vivo human PCa tissues using NIR-II fluorescence imaging technology. Analyzing tissue samples from 60 clinical cases of PCa, along with benign prostatic hyperplasia and normal prostate tissue from 22 cases, we observed a significant difference in B7-H3 protein expression levels (P < 0.001). Subcutaneous and orthotopic mouse models of PCa were imaged using NIR-II fluorescence after AbB7-H3-800CW injection, showing promising results with successful tumor targeting and high-contrast images achieved within 24-48h post-injection. The imaging also enabled the detection of occult PCa lesions approximately 1mm in diameter. In addition, imaging analysis of human PCa and adjacent tissues using AbB7-H3-800CW incubation revealed that cancer tissues exhibited a significantly higher fluorescence intensity than adjacent tissues (P < 0.05), which was conducive to the evaluation of tumor resection margin in vitro. The findings revealed that B7-H3 was a compelling imaging target for PCa. The AbB7-H3-800CW molecular imaging probe is capable of accurately identifying PCa lesions and guiding their removal. This approach can potentially reduce the rate of surgical margins under NIR-II fluorescence guidance.