Given the diverse socioecological consequences of rapid urban sprawl worldwide, the delineation and monitoring of urban boundaries have been widely used by local governments as a planning instrument for promoting sustainable development. This study demonstrates a fractal method to delineate urban boundaries based on raster land use maps. The basic logic is that the number of built-up land clusters and their size at each dilation step follows a power-law function. It is assumed that two spatial subsets with distinct fractal characteristics would be obtained when the deviation between the dilation curve and a straight line reaches the top point. The top point is regarded to be the optimum threshold for classifying the built-up land patches, because the fractality of built-up land would no longer exist beyond the threshold. After that, all the built-up land patches are buffered with the optimum threshold and the rank-size distribution of new clusters can be re-plotted. Instead of artificial judgement, hierarchical agglomerative clustering is utilized to automatically classify the urban and rural clusters. The approach was applied to the case of Shanghai, the most rapidly urbanizing megacity in China, and the dynamic changes of the urban boundaries from 1994 to 2016 were analyzed. On this basis, urban–rural differences were further explored through several fractal or nonfractal indices. The results show that the proposed fractal approach can accurately distinguish the urban boundary without subjective choice of thresholds. Extraordinarily different fractal dimensions, aggregation and density and similar average compactness were further identified between built-up land in urban and rural areas. The dynamic changes in the urban boundary indicated rapid urban sprawl within Shanghai during the study period. In view of the popularization and global availability of raster land use maps, this paper adds fuels to the cutting-edge topic of distinguishing the morphological criteria to universally describe urban boundaries.