POKROVSK, Ukraine—During a break from fighting the Russians, an avuncular rifleman recalled how he was going for a haircut one day when he was press-ganged into joining the Ukrainian army.

Three recruitment officials accosted the stocky, gray-haired 47-year-old outside the barber shop in his small hometown, ordered him to get in a car and detained him for two days in a dark room at the local draft center until he had signed up.

“I got my haircut at the training camp,” he said.

Now known by his military call sign Dubok, the former electrical engineer offered to serve as a technician in the rear. “But to get that job, you have to pay bribes,” he said. Instead, he was sent to join an infantry unit depleted by months of hard fighting. His battalion of the 47th Mechanized Brigade is defending the city of Avdiivka against waves of Russian assaults, the biggest current battle in Russia’s relentless war on Ukraine.

“Physically, I can’t handle this,” Dubok said of front-line combat. “I’m deeply disappointed that I’m no longer 20.”

Ukraine needs to rebuild its battered army. The infantry, which bears the brunt of deaths and injuries, is chronically short of men after nearly two years of resisting Russia’s full-blown invasion.

The most highly motivated fighters volunteered early. Those who haven’t been killed or wounded often say they are exhausted. Ukraine now relies on the draft—and sometimes on rounding up men—to replenish the ranks. Meanwhile, Russia can draw on a much larger population to replace its own heavy losses.

Members of the Siberian Battalion of the Ukraine’s Armed Forces International Legion attend military exercises, amid Russia’s attack on Ukraine, at an undisclosed location in Kyiv region, Ukraine December 13, 2023. REUTERS/Valentyn Ogirenko

But a rickety draft system isn’t mobilizing Ukraine’s manpower effectively, providing the quantity and quality of troops needed, or sharing the burden fairly across Ukrainian society, say many soldiers and military analysts.

A combination of corruption, exemptions and political caution has protected much of Ukraine’s urban middle class against having to fight in the cold and muddy trenches. On the long front line, a disproportionate share of draftees are middle-aged men like Dubok. Often they are from villages and small towns and were too poor to buy their way out.

Veteran soldiers who have been fighting since 2022—some since 2014, when Russia first invaded Ukraine’s east—express frustration that new recruits are often past their physical prime.

“The quality of the replacements is not good. They’re rural guys aged 43 to 50, sometimes with health problems,” said an experienced infantryman fighting near Avdiivka.

Tired fighters note bitterly that when they go on leave in big cities such as Kyiv or Dnipro, they see able-bodied men in their 20s and 30s frequenting gyms, bars and hip restaurants.

“We don’t have full-on mobilization” of society, said a drone operator with the Ukrainian Navy’s special forces, known by his call sign Dobro. “But it’s a necessity. We can’t do without it.”

Ukrainian President Volodymyr Zelensky said on Tuesday that the military was asking him for up to 500,000 more troops. He said no decision has been taken, calling the issue “very sensitive.” He noted that many soldiers who have been fighting a long time will also need to be demobilized at some point.

Dubok, the 47-year-old, didn’t protest or resist when he was detained at the draft center. “I went to school with the guys who processed me. I didn’t want to create problems for them,” he said. He had been thinking about joining the military anyway. “But not this way,” he said.

A Ukrainian serviceman of the Ukrainian 92nd Ivan Sirko Separate Assault Brigade covers his ear during fire from a 2S1 Gvozdika self-propelled howitzer toward Russian troops in a front line near the town of Bakhmut, amid Russia’s attack on Ukraine, in Donetsk region, Ukraine December 15, 2023. REUTERS/Inna Varenytsia

Ukrainian servicemen of the Ukrainian 92nd Ivan Sirko Separate Assault Brigade have their meals inside a dugout at a position in a front line near the town of Bakhmut in Donetsk region, Ukraine December 15, 2023.

The day Dubok was drafted, his wife was left waiting for him at home with strawberries and cream. Now he watches rats feasting on dead bodies in the muddy battlefield around Avdiivka. “I’ve never seen such big rats in my life,” he said.

Stories of men being confronted in the street and detained by draft officials abound in Ukraine. Some incidents have been filmed and put on the internet. “It’s unlawful. They can only hand out draft notices, not detain people,” said Serhiy Parokhnenko, a lawyer from Dnipro whose clients include men challenging their call-up.

A Defense Ministry official admitted violations by some local recruitment staff but said too many citizens are ignoring their army summons.

Finding willing recruits for the infantry is proving especially difficult in the current phase of attritional warfare. The West’s fading support for Ukraine is darkening the country’s mood, and making front-line combat even more daunting.

Growing Republican opposition in Congress has held up U.S. military and financial aid. European Union aid is being impeded by Hungary, whose leader Viktor Orban has long had warm relations with Moscow.

Western deliveries of arms and ammunition have slowed sharply. Russia has regained a clear advantage in artillery firepower, where Ukraine had parity earlier this year.

About 800,000 people serve in Ukraine’s armed forces, Defense Minister Rustem Umerov said recently. Casualties in the war are a tightly held secret, but full hospitals and graveyards around Ukraine show the high price the country is paying to defy Russia’s attempted conquest.

On paper, Ukraine still has a large reserve of potential manpower, with several million male residents in their 20s and 30s who have yet to fight. The military hasn’t drafted men under the age of 27 so far, although Parliament has authorized a lower age limit of 25. Groups exempt from the draft include fathers of several children, carers for disabled people and workers in key sectors.

Ukraine’s government had hoped that this summer’s counteroffensive, aimed at retaking swaths of Russian-occupied territory, would go a long way toward winning the war—and obviate the need for a politically unpopular push to draft more young people in Kyiv.

Instead, Ukrainian assault troops made few dents in Russia’s heavily fortified lines. Casualties compounded the infantry’s losses in the grueling 10-month defense of the city of Bakhmut, which fell to Russian forces this spring.

“Sad news from the front is discouraging citizens from joining,” said Dobro, the drone operator. Ukrainian army commanders who use costly Soviet-style tactics of frontal assaults are adding to people’s fear of being drafted, he said. “Now people realize that if you want to live to see the end of the war, you shouldn’t go to the infantry.”

Army advertisements acknowledge people’s trepidations. Recruitment posters tell people “it’s brave to admit your fears.”

An unknown number of Ukrainians have left the country to avoid the draft, paying bribes so they can cross the border. Ukraine’s wartime laws ban most men age 18 to 60 from traveling abroad. Exceptions include men who are medically unfit to serve, volunteers for charities and some traveling for work.

Earlier this year, a 30-year-old architect from Odesa paid a bribe of about $7,600, more than half of his savings, to a doctor for a medical certificate exempting him from the draft. He then packed his possessions into his car and drove across the border into Moldova. “I’m supportive of Ukraine. It’s a great country, with great people,” he said. “But I don’t want to die.”

Now living in southern Europe, he said some of his friendships in Ukraine have frayed because of his decision. Other friends have told him he is lucky to be abroad. He said he donates money to support friends who are fighting.

The biggest corruption problem is at draft offices. Reports of officials taking bribes to let men off became so widespread that Zelensky fired all 24 of the country’s regional recruitment chiefs in August. But the government has yet to announce a more thorough overhaul of recruitment, despite months of talking about the need for changes.

The Defense Ministry’s ideas for reforms include hiring private-sector recruitment firms, creating a national digital registry of fighting-age men to make the draft more transparent and evasion harder, registering women, too, and letting people apply directly for armed-forces jobs that suit their skills and qualifications.

The large number of draftees in their 40s has raised eyebrows among allied Western countries that are helping to train them. “Ukraine has taken a conscious decision to mobilize more mature people for conflict,” Gen. Patrick Sanders, chief of the British Army, told the U.K. Parliament recently. “They are protecting their young men and women for the sake of the future of the economy,” he said.

Others are less charitable. “The bias in age and geography stems from corruption,” said Ihor Romanenko, a military analyst and retired Ukrainian lieutenant general. Young people in big cities can more often afford a bribe, while big companies can shield their employees from the draft, he said. In rural Ukraine, where the population skews older, it is harder to hide from the draft. “In a village, everyone knows everyone,” he said.

“Especially in the infantry, people over 35 have less potential to fulfill their mission than younger men,” said Romanenko. “Of course, you have to preserve the youth. But our country is fighting for its existence.”

—Bertrand Benoit and Max Colchester contributed to this article.

Write to Marcus Walker at Marcus.Walker@wsj.com