Computed tomography (CT) scan pictures are routinely employed in the automatic identification and classification of lung cancer. The texture distribution of lung nodules can vary widely over the CT scan space and requires accurate detection. The evaluation of discriminative information in this volume can tremendously aid the classification process. A convolutional neural network, the Attention Gate Residual U-Net model, and KNN classifiers are utilized to detect lung cancer. The dataset of 1097 computed tomography (CT) images utilized in this study was obtained from the Iraq-Oncology Teaching Hospital/National Centre for Cancer Diseases (IQ-OTH/NCCD) to segment and classify lung tumors from CT images using the novel Attention Gate Residual U-Net model, i.e., AGResU-Net and CNN architecture. The initial step is applying CNN to detect normal, benign, and malignant patients in CT images. Second, use AGResU-Net to partition lung tumour areas. In the third section of the project, a KNN classifier is used to determine if an instance is malignant or benign. In the initial phase, CNN was proposed to classify three distinct regions. Three optimization strategies are used in this work: Adam, RMSP, and SGDM. The classifier’s accuracy is 97%, 85%, and 82%, respectively. When compared to the RMSP optimizer, the Adams optimizer predicts probability rates more accurately. In the second phase, AGResU-Net is used for schematic segmentation of the tumor region. In the third phase, a KNN classifier is used to classify benign and malignant tumor from the segmented tumor regions. A new segmentation of the lung tumor model is proposed. In this developed algorithm, the labelled classified data set and the segmented tumor output result provide the same accuracy. The study results demonstrate high tumour classification accuracy and high probability of detection in benign and malignant cases.