In 1918, after Lithuania declared its independence, the city's name was changed from Vilkmergė to Ukmergė. In 1919 Bolshevik forces occupied the city during the Lithuanian–Soviet War, but it was soon liberated by the Lithuanian army led by Jonas Variakojis. Over five hundred Bolshevik prisoners were taken during the Battle of Ukmergė.