Ukrainian soldiers announced the capture in a video recorded outside the town council building and posted on social media.
Russia's defence ministry officially announced it was pulling troops out of the area "in connection with the creation of a threat of encirclement".
The stinging defeat prompted Moscow’s close ally, the leader of Russia's southern Chechnya region, Ramzan Kadyrov to call for the possible use of low-grade nuclear weapons.
The capture on Friday evening came just hours after Moscow proclaimed the annexation of nearly a fifth of Ukraine-including Donetsk, where Lyman is located - and placed the regions under Russia's nuclear umbrella. Kyiv and the West condemned the ornate ceremony as an illegitimate farce.
Lyman had fallen in May to Russian forces, which had used it as a logistics and transport hub for its operations in the northof the Donetsk region. Its capture is Ukraine's biggest battlefield gain since the lightning counteroffensive in the northeastern Kharkiv region last month.
President Volodymyr Zelensky promised more quick successes in the Donbas, which covers the Donetsk and Luhansk regions that are largely under Russian control.