(Recasts) By Kristin Roberts RAWALPINDI, Pakistan, Feb 12 (Reuters) - U.S. Defense Secretary Robert Gates discussed plans for a spring offensive against the Taliban and al Qaeda in Afghanistan when he met Pakistani President Pervez Musharraf on Monday. Gates, on his first trip to Pakistan since his appointment, spoke of taking the initiative away from an enemy that has also threatened a fresh offensive once the weather turns warmer. "We discussed the coming spring military activity on the border and the measures that the Afghans, the NATO alliance, the United States and Pakistan working together can take," Gates said, referring to his talks with Musharraf. "We talked about the importance of seizing the offensive this spring to deal the Taliban and al Qaeda a strategic set-back," he told reporters at a military airport in the garrison city of Rawalpindi before returning to Washington. "We have a real opportunity this spring." Pakistan is an important U.S. ally in counter-terrorism, but U.S. officials have often voiced frustration over Taliban sanctuaries on the Pakistani side of the porous border. Gates' remarkable 30-hour side trip for a one-hour visit with Musharraf appeared to be an attempt at delicate diplomacy. It followed Gates' January trip to Afghanistan, where U.S. commanders told him militant attacks from Pakistan into Afghanistan had surged. Military officials also have said the Afghan insurgency's command operations came from the Pakistani side of the border and that training, financing, indoctrination, regeneration and other support activities were taking place there as well. Pakistani officials have rejected blame for the increase in Taliban violence, saying the core problems lay in Afghanistan. "STRONG ALLY" Gates stressed Washington's appreciation for Pakistan's help in a U.S.-led war on terrorism and on the Afghan border. "Pakistan is clearly a very strong ally of the United States on this," he said. "My sense is Pakistan is playing a very constructive role. It's incurring significant cost in lives and, I might add, in treasure in fighting this battle on the border," he said. "There are always ways that all of us can improve, that includes NATO, the United States, the Afghans." But helping the United States is politically sensitive for Pakistani leaders, as anti-American sentiment is rife in the country, and there have been no arrests of senior Taliban leaders in Pakistan. Pakistan has not allowed U.S. forces to operate from its territory, or attack militants across the border. Asked to comment on reports U.S. forces in Afghanistan have been firing artillery at Taliban targets in Pakistan, Gates merely said: "Our operations are coordinated with the Pakistanis." Gates also said the United States would not repeat the mistake of neglecting Afghanistan and allowing it to become a haven for Islamist militants. "My first visits to Pakistan were over 20 years ago and were in connection with our mutual effort to help the Afghans drive the Soviet troops from their territory," Gates said. "After the Soviets left, the United States made a mistake. We neglected Afghanistan and extremism took control of that country," he said, citing the Sept. 11, 2001, attacks. "We won't make that mistake again. We are here for the long haul."