Ukraine has begun releasing prisoners to serve in its army, part of a wider effort to rebuild a military that has been depleted by more than two years of war and is strained by relentless Russian assaults.

Denys Maliuska, Ukraine’s justice minister, said in an interview Friday that nearly 350 prisoners had already been freed under a law enacted last week that allows convicts to serve in the army in exchange for the possibility of parole at the end of their service.

The country’s courts must approve each prisoner’s bid to enlist, and Maliuska said the judiciary was already considering most of the 4,300 applications submitted so far. Up to 20,000 such applicants, including people who were in pretrial detention, could be recruited to join the hundreds of thousands of soldiers already serving in Ukraine’s military, he said.