ISLAMABAD, Pakistan — Prime Minister Imran Khan of Pakistan offered on Tuesday to investigate allegations by New Delhi that a Pakistan-based militant group was behind a deadly suicide attack on Indian troops in Kashmir, but he warned that his country would retaliate against any Indian military action.

Mr. Khan’s comments were the first formal response by the Pakistani leader since the bombing on Thursday, the worst in the disputed Himalayan region of Kashmir in 30 years. Jaish-e-Muhammad, or the Army of Muhammad, a Pakistan-based militant group, claimed responsibility for the attack. Tensions have since risen sharply between India and Pakistan, and both countries have recalled their ambassadors for consultations.

In his statement, Mr. Khan said he had been focused on a visit by the Saudi crown prince, Mohammed bin Salman, who arrived in Pakistan on Sunday for a two-day visit that has led to pledges of $20 billion of investment from Saudi Arabia.