Accurate segmentation of lung lesions in CT-scan images is essential to diagnose lung cancer. The challenges in lung nodule diagnosis arise due to their small size and diverse nature. We designed a transformer-based model EDTNet (Encoder Decoder Transformer Network) for PNS (Pulmonary Nodule Segmentation). Traditional CNN-based encoders and decoders are hindered by their inability to capture long-range spatial dependencies, leading to suboptimal performance in complex object segmentation tasks. To address the limitation, we leverage an enhanced spatial attention-based Vision Transformer (ViT) as an encoder and decoder in the EDTNet. The EDTNet integrates two successive transformer blocks, a patch-expanding layer, down-sampling layers, and up-sampling layers to improve segmentation capabilities. In addition, ESLA (Enhanced spatial aware local attention) and EGLA (Enhanced global aware local attention) blocks are added to provide attention to the spatial features. Furthermore, skip connections are introduced to facilitate symmetrical interaction between the corresponding encoder and decoder layer, enabling the retrieval of intricate details in the output. The EDTNet performance is compared with several models on DS1 and DS2, including Unet, ResUNet++, U-NET 3+, DeepLabV3+, SegNet, Trans-Unet, and Swin-UNet, demonstrates superior quantitative and visual results. On DS1, the EDTNet achieved 96.27%, 95.81%, 96.15% precision, IoU (Intersection over Union), and DSC (Sorensen–Dice coefficient). Moreover, the model has demonstrated sensitivity, IoU and SDC of 98.84%, 96.06% and 97.85% on DS2.