Urban development greatly alters the natural and semi‐natural habitats of native plants. Urbanisation results in a range of diverse habitats including remnant agricultural lands, urban parks, and roadside habitats. This habitat diversity often promotes trait divergence within urban areas. However, the mechanisms by which diverse urban habitats influence the population genetic structure of individual plant species remain poorly understood. We investigated the effects of urbanisation on genetic diversity and structure within 24 Commelina communis populations across diverse habitat types (rural agricultural land, urban agricultural land, urban park land, and urban roadsides) within the Kyoto–Osaka–Kobe megacity in Japan. We conducted multiplexed inter‐simple sequence repeat genotyping to compare genetic diversity among populations in different habitats. We also examined the correlation between Nei's genetic distance and geographic and environmental distances and performed principal coordinate analysis (PCoA) to evaluate genetic differentiation among urban habitats. There were no significant differences in genetic diversity indices between urban and rural populations and among urban habitat types. Although we detected no isolation‐by‐distance structure in population pairs of the same habitat type and in those of different habitats, the difference in surrounding landscape facilitated genetic differentiation not only between urban and rural habitats but also between different urban habitats. PCoA revealed no clear genetic differentiation among rural and urban habitat populations. Our findings indicate that the establishment of diverse habitat types through urbanisation has no and little impact on genetic diversity and structure, respectively, in C. communis, likely due to its high selfing rate and ability to adapt to urban conditions.