Synthetic aperture radar (SAR) has become an important part of ship detection due to its all-day all-weather characteristics. Ship monitoring is important for coastal traffic control and territorial safety. Ship detection requires high accuracy, but the speed of ship detection is also an important parameter in making rapid decisions, such as those in maritime rescue and military strategy. However, fast networks tend to be less accurate. To address this problem, we propose an efficient localization method based on a spatial attention mechanism. This mechanism uses gridguided localization instead of a frame regression mechanism, which makes the network faster but also lowers the accuracy to a level insufficient for direct application to SAR image target detection. A tested and selected spatial attention mechanism improves the detection accuracy while guaranteeing its speed. It is shown that four factors affect the design of the spatial attention mechanism, namely query and key content, query content and relative position, key content, and relative position. These factors are ordered, and the group with the best precision is added to the proposed network. The proposed network can achieve a good detection effect for sparsely distributed targets in SAR images, and the proposed algorithm can achieve AP 50∶75 , AP 50 , AP 75 , and AP S values of 71.3%, 96.9%, 86.6%, and 72.1%, respectively, on the SAR ship detection dataset.