ISTANBUL — Kurdish militants killed at least 24 Turkish soldiers in an attack near the Iraq border on Wednesday, one of the deadliest strikes in years, and Turkey’s military responded by sending hundreds of troops into northern Iraq in a counterattack on Kurdish insurgent hide-outs.

Prime Minister Recep Tayyip Erdogan said that Turkish forces were pursuing the attackers, making it clear that his military was crossing the Iraq border, which the Turks have done numerous times in their protracted effort to crush a resilient Kurdish insurgency movement.

“As of now, wide-reaching operations, including hot-pursuit operations, are continuing in the region within the framework of international law,” Mr. Erdogan said at a news conference in Ankara. “We will combat terror on one front and, on another front, we will continue our path to destroy the grounds that terror manipulates.”

He spoke after having conferred with senior government officials at an emergency meeting about the deadly Kurdish militant attack, which the prime minister’s office said had also left at least 18 Turkish soldiers wounded.