This paper presents a new algorithm for Gleason grading of pathological images of prostate. Structural features of the glands are extracted and used in a tree-structured (TS) algorithm to classify the images into five Gleason grades of 1 to 5. In this algorithm the image is first segmented to locate the glandular regions using texture features and a <i>K</i>-means clustering algorithm. The glands are then labeled from the glandular regions. In each stage of the proposed TS algorithm, shape and intensity-based features of the glands are extracted and used in a linear classifier to classify the image into two groups. Despite some proposed methods in the literature which use only texture features, this technique uses the features like roundness and shape distribution, which are related to the structure of the glands in each grade and are independent of the magnification. The proposed method is therefore robust to illumination and magnification variations. To evaluate the performance of the proposed method, we use two datasets. Data set 1 contains 91 images with similar magnifications and illuminations. Data set 2 contains 199 images with different magnifications and illuminations. Using leave-one-out technique, we achieve 95% and 85% accuracy for dataset 1 and 2, respectively.