KABUL, Afghanistan - The departing American commander of NATO forces in Afghanistan said the insurgency there would last for years unless Pakistan shut down safe havens where militants train and recruit.

Gen. Dan McNeill also blamed new peace agreements in Pakistan's tribal areas for a spike in violence in eastern Afghanistan, where U.S. forces operate along the border.

"If there are going to be sanctuaries where these terrorists, these extremists, these insurgents can train, can recruit, can regenerate, there's still going to be a challenge there," McNeill said in an interview.

NATO has said there was a 50 percent spike in violence in eastern Afghanistan in April compared with 2007.

"We've also monitored and reported in the past what happens when there are so-called peace negotiations with these terrorists and extremists inside those sanctuaries," McNeill said. "And when there have been [negotiations], there has been a spike in the untoward events on our side of the border."

McNeill, 61, a four-star general from North Carolina who has fought in most American conflicts since Vietnam, will step down next week as commanding officer of the 40-nation International Security Assistance Force. He will be replaced by Gen. David D. McKiernan, the commanding general of the U.S. Army in Europe.

McKiernan will inherit a greatly expanded force compared with the one McNeill took command of in February 2007, when it had 36,000 troops. Today, it has 51,000. McNeill said in the interview that the increase was proof of the international community's commitment to success in Afghanistan.

"That says to me that all the wags who in late 2006 and early 2007 who were predicting the failure and the fracture of the NATO alliance here probably got it wrong," he said. "And I'm not trying to smirk or anything; I'm just saying people ought to go back and see what was being written."

There is also a record number of U.S. forces in the country - 33,000, including 2,400 Marines who arrived this spring to battle insurgents in the south, where ISAF has not had enough troops. McNeill said the United States would probably send more troops to the south next year.

Violence and the drug trade have also spiked on McNeill's watch. Insurgents last year set off a record number of suicide bombs - more than 140. More than 8,000 people, mostly militants, died in violence, according to U.N. analysts. Former military officers have warned that the international effort is in danger of failing.

McNeill said the NATO force in Afghanistan was short of troops. "It's an under-resourced force," he said. "That's been a constant theme since I've been here."

McNeill said he would not recommend that Marines become the primary U.S. fighting force in Afghanistan, because their tour lengths were too short for effective counterinsurgency operations, which require that strong relationships be built with local leaders.

But he also said the 24th Marine Expeditionary Unit, which has been battling militants in the Garmser district of southern Helmand province, "is producing some really good effects . . . and I'm also going to admit that they're a little better than anticipated."