Underwater object detection (UOD) is crucial for developing marine resources, environmental monitoring, and ecological protection. However, the degradation of underwater images limits the performance of object detectors. Most existing schemes treat underwater image enhancement (UIE) and UOD as two independent tasks, which take UIE as a preprocessing step to reduce the degradation problem, thus being unable to improve the detection accuracy effectively. Therefore, in this paper, we propose a dual-branch joint learning network (DJL-Net) that combines image processing and object detection through multi-task joint learning to construct an end-to-end model for underwater detection. With the dual-branch structure, DJL-Net can use the enhanced images generated by the image-processing module to supplement the features lost due to the degradation of the original underwater images. Specifically, DJL-Net first employs an image decolorization module governed by the detection loss, generating gray images to eliminate color disturbances stemming from underwater light absorption and scattering effects. An improved edge enhancement module is utilized to enhance the shape and texture expression in gray images and improve the recognition of object boundary features. Then, the generated edge-enhanced gray images and their original underwater images are input into the two branches to learn different types of features. Finally, a tridimensional adaptive gated feature fusion module is proposed to effectively fuse the complementary features learned from the two branches. Comprehensive experiments on four UOD datasets, including some scenes with challenging underwater environments, demonstrate the effectiveness and robustness of the proposed DJL-Net.