Ukraine’s forces swept into the key southern city of Kherson on Friday, after Russian troops completed their withdrawal from the regional capital in one of the Kremlin’s most significant strategic and symbolic defeats since the invasion began.

According to videos posted online by Ukrainian officials, cheering Ukrainians welcomed the arriving troops and raised their national flag in a public square in the center of Kherson, the only regional capital that Russia had seized since February. A crowd of ecstatic locals carried Ukrainian soldiers on their shoulders. Residents also raised a European Union flag, reflecting many Ukrainians’ long-held desire to strengthen ties with the bloc.

“Honor to heroes. Enemies will perish. Above all, Ukraine!” yelled the crowd.

“Ukrainian troops are entering Kherson,” Ukrainian military intelligence said in a statement, ordering any remaining Russian soldiers to surrender or perish.

The Russian Defense Ministry announced on Friday that troops had been transferred to the city’s east bank of the Dnipro River. It was not immediately clear if any Russian soldiers remained on the western bank.

Russia’s withdrawal from Kherson is a major military setback for Russian President Vladimir Putin, who claimed in September that he had absorbed the region around the city into Russian territory. Kherson, a strategic Black Sea port city, was also central to Russia’s early attempts to seize Ukraine’s vital economic centers.

The Ukrainian advance is the war’s second abrupt shift in less than three months, following the recapture of a swath of territory in the country’s northeast in September. It also likely puts an end to Russia’s plans to advance toward Odessa, Ukraine’s largest coastal city and port.

After months of fighting to push back occupying Russian forces, the advance was a significant morale boost for Ukrainians. According to a video tweeted by Ukrainian Foreign Minister Dmytro Kuleba, Ukrainians could be seen tearing down a billboard that read “Russia is here forever” in Bilozerka, a town just outside the city of Kherson.

Russia seized Kherson in March as part of the first phase of its full-scale assault on Ukraine, marking one of the country’s most significant early combat victories. The city’s capture triggered months of fighting in which Ukrainian forces fought to retake it.

For months, Ukrainian forces attempted to cut off Russian supply lines to troops on the Dnipro’s west bank, using long-range artillery supplied by the United States to cut off Moscow’s forces in the area and eventually force a Russian retreat while saving the city from the death and destruction of full-scale urban fighting.

Finally, Ukraine’s recapture of Kherson after Russia’s withdrawal avoided a more costly scenario in which Ukrainian forces fought their way into the city street by street or attempted to starve out Russian forces over the winter months.

According to a photograph from Ukrainian media and a video posted by a Russian journalist, the Antonivsky bridge, a key crossing point over the Dnipro, appeared to be severely damaged. The image and video, both confirmed by video intelligence agency Storyful, showed several sections of the bridge collapsing. The cause of the damage could not be determined right away.

According to Anton Gerashchenko, a Ukrainian Ministry of Internal Affairs official, Russia blew up the bridge to stymie the Ukrainians’ advance. The Russian Ministry of Defense did not immediately respond to an inquiry about whether Russian forces destroyed the bridge.

According to Defense Ministry officials, over 30,000 Russian military personnel and 5,000 pieces of arms, military hardware, and property have been transferred to the Dnipro’s east bank. According to them, Russian forces continued to pound Ukrainian troops on the west bank after regrouping in the Kherson area.

The Kremlin’s propaganda machine has put on a brave face in the face of Russia’s retreat, portraying it as a wise and necessary step to regroup and avoid troop losses, while some conservative hardliners, already enraged by a string of battlefield defeats, have condemned the surrender of Kherson. Mr. Putin, who said in September that residents of the Kherson region and three other Ukrainian territories at least partly under Moscow’s control had become Russian citizens forever, has remained silent on the order to retreat.