Urban power grid (UPG) combines transmission and distribution networks. Past studies on UPG congestion mitigation have focused on relieving local congestion while ignoring large-scale energy transfer with safety margins load balancing. This situation is expected to worsen amid the proliferations of renewable energies and electric vehicles. In this paper, a two-layer congestion mitigation framework is proposed, which considers the congestions of UPG with flexible topologies. In the upper-layer, the PSO algorithm is employed to optimize the power supply distribution (PSD) of substation transformers, known as upper-layer PSD. The lower-layer model recalculates the new PSD, known as the lower-layer PSD, based on the topology candidates. A candidate topology is optimum when the Euclidean distance mismatch between the upper- and lower-layer PSDs are the smallest. This optimum topology is tested by the standard power flow to ascertain its feasibility. The optimum transitioning sequence between the initial and optimum topologies is also determined by the two-layer framework to minimize the voltage deviation and line overloading of UPG considering dynamic thermal rating. The proposed framework is tested on a 56-node test system. Results show that the proposed framework can significantly reduce congestion, maintain safety margins, and determine the optimum transitioning sequence.