Mangrove forests are significant participants in coastal ecological environment systems. For the development of protection strategies, it is crucial to automatically and accurately detect the distribution and area of mangroves using satellite images. Although many deep-learning-based mangrove detection and segmentation algorithms have made notable progress, the complex regional structures and the great similarity between mangroves and the surrounding environment, as well as the diversity of mangroves, render the task still challenging. To cover these issues, we propose a novel deep-supervision-guided feature aggregation network for mangrove detection and segmentation called MangroveSeg, which is based on a U-shaped structure with ResNet, combining an attention mechanism and a multi-scale feature extraction framework. We also consider the detection and segmentation of mangroves as camouflage detection problems for the improvement and enhancement of accuracy. To determine more information from extracted feature maps in a hidden layer, a deep supervision model is introduced in up-sampling to enhance feature representation. The spatial attention mechanism with attention gates is utilized to highlight significant regions and suppress task-independent feature responses. The feature fusion module can obtain multi-scale information by binding each layer to the underlying information and update feature mappings. We validated our framework for mangrove detection and segmentation using a satellite image dataset, which includes 4000 images comprising 256 × 256 pixels; we used 3002 for training and 998 for testing. The satellite images dataset was obtained from the Dongzhaigang National Nature Reserve located in Haikou City, Hainan Province, China. The proposed method achieved a 89.58% overall accuracy, 89.02% precision, and 80.7% mIoU. We also used the trained MangroveSeg model to detect mangroves on satellite images from other regions. We evaluated the statistical square measure of some mangrove areas and found that the evaluation accuracy can reach 96% using MangroveSeg. The proposed MangroveSeg model can automatically and accurately detect the distribution and area of mangroves from satellite images, which provides a method for monitoring the ecological environment.