KIEV, Ukraine — When pro-Russian rebels first fanned out across eastern Ukraine in April, seizing public buildings, ousting local officials and blockading streets and highways, the government’s security forces — a ragtag lot of poorly equipped and understaffed military and police units — were largely paralyzed by dysfunction and defection. They seemed to remain so for months.

In the past week, however, after President Petro O. Poroshenko called off a cease-fire and ordered his troops to end the rebellion by force, an entirely different Ukrainian military appeared to arrive at the front. Soldiers retook an important checkpoint at the Russian border, routed insurgents from the long-occupied city of Slovyansk, and, on Sunday, began to tighten a noose around the regional capital of Donetsk ahead of a potentially decisive showdown.

The insurgency is far from over, and Ukraine’s leaders say they still fear a war with Russia that they would certainly lose. Still, the recent success, however tentative, reflects what officials and analysts described as a remarkable, urgent transformation of the military and security apparatus in recent months.

“The military themselves learned to fight,” said Mykola Sungurovskyi, the director of military programs at the Razumkov Center, a policy research organization here in the capital of Ukraine.