To address the issue of insufficient extraction of target features and the resulting impact on detection performance in long-range infrared aircraft target detection caused by small imaging area and weak radiation intensity starting from the idea of perceiving target context to enhance the features extracted by convolutional neural network, this paper proposes a detecting algorithm based on AWFGLC (adaptive weighted fusion of global–local context). Based on the mechanism of AWFGLC, the input feature map is randomly reorganized and partitioned along the channel dimension, resulting in two feature maps. One feature map is utilized by self-attention for global context modeling, establishing the correlation between target features and background features to highlight the salient features of the target, thereby enabling the detecting algorithm to better perceive the global features of the target. The other feature map is subjected to window partitioning, with max pooling and average pooling performed within each window to highlight the local features of the target. Subsequently, self-attention is applied to the pooled feature map for local context modeling, establishing the correlation between the target and its surrounding neighborhood, further enhancing the weaker parts of the target features, and enabling the detecting algorithm to better perceive the local features of the target. Based on the characteristics of the target, an adaptive weighted fusion strategy with learnable parameters is employed to aggregate the global context and local context feature maps. This results in a feature map containing more complete target information, enhancing the ability of the detection algorithm to distinguish between target and background. Finally, this paper integrates the mechanism of AWFGLC into YOLOv7 for the detection of infrared aircraft targets. The experiments indicate that the proposed algorithm achieves mAP50 scores of 97.8% and 88.7% on self-made and publicly available infrared aircraft datasets, respectively. Moreover, the mAP50:95 scores reach 65.7% and 61.2%, respectively. These results outperform those of classical target detection algorithms, indicating the effective realization of infrared aircraft target detection.