The U.S. CIA recently revealed that they believe there are fewer than a hundred al Qaeda members in Afghanistan. Many more (over a thousand) are across the border in Pakistan. The reasons for this disparity are many. First, it's easier to operate in Pakistan, because many areas of the Pakistani tribal territories are free of government security forces. It has been that way for centuries. Across the border, NATO and Afghan forces are free to go anywhere in Afghanistan to seek out al Qaeda. Another reason is racism. Arabs, who are dominant in al Qaeda, despise Afghans (and non-Arabs in general, for that matter.)
There have always been ethnic tensions within al Qaeda, and since September 11, 2001, more members of the group have been turning on each other because of these tensions. One of al Qaedas weaknesses is that it is dominated by Arabs. This often causes resentment when the non-Arabs find themselves left out of decision making, or on the short end when it comes to distribution of resources. This was first seen in Afghanistan, where the al Qaeda Arabs made themselves very unpopular several years before September 11, 2001. Now the bad feelings have spread to Pakistan. There, hundreds of al Qaeda members hiding out in tribal areas along the Afghan border, split along ethnic lines. The Arab al Qaeda, who still had access to lots of cash, made themselves very unpopular with the al Qaeda members from Central Asia. The Central Asians, particularly Islamic radicals from Uzbekistan, always felt this was their turf, and that the Arab al Qaeda should recognize that, and not throw their weight, and money, around in a disrespectful (to the Uzbeks) manner. Apparently, some of the al Qaeda leaders captured in Pakistan over the last few years were the result of non-Arab al Qaeda giving up information they could have kept to themselves.
The Arab attitude problem in Afghanistan first showed up in the 1980s, when the Gulf Arabs contributed billions of dollars to the Afghan effort to fight the Russians in Afghanistan. The Arabs who showed up with this cash, viewed the Afghans as a bunch of uneducated hicks, and the Afghans picked up on this. Its true that many of the senior Arab al Qaeda were well educated, much better than the average Afghan, but they would have been wise to keep any feelings of superiority to themselves. But they didnt, and while there appear to have been attempts to act more diplomatically after al Qaeda survivors were driven into Pakistan in late 2001, this didnt last.
After 2001, the basic problem for al Qaeda was self-preservation. The Pakistani army and intelligence forces came down hard on al Qaeda after the terrorists declared war on the Pakistani government in 2002. The al Qaeda led terrorists killed hundreds of Pakistanis and made several assassination attempts on the Pakistani president. When the Pakistani army showed up in the tribal territories a few years ago, many of the tribes were no longer willing to host the terrorists. The army had never come into the tribal territories before, and the tribes knew the soldiers were there now because of the al Qaeda threat to the government. The tribes could understand that, and knew that the army meant business.
The army was also willing to negotiate, and eventually get out of the territories if the al Qaeda members were handed over. Some tribes, or tribesmen, refused to do this. But there were fewer hiding places now, and the Arabs used their greater cash resources to save themselves, at the expense of Central Asian terrorists. Whatever bad feelings that existed between the Arabs and Central Asians before, now became much worse. This led to captured Central Asians giving up information on where Arab al Qaeda might be. This, combined with information obtained from tribesmen and other captured terrorists, led to the round up of dozens of key al Qaeda leaders in the last few years.
The foreign al Qaeda members were unpopular in both Afghanistan and Pakistan, but the hatred was much more intense because of the al Qaeda brigade. This goes back to the late 1990s, when the Taliban used a brigade of al Qaeda gunmen to keep unruly tribes in line. Most of the al Qaeda enforcers were Arabs, who did not hide their disdain for the "primitive" Afghans. This has not been forgotten. Moreover, Arabs stand out more in Afghanistan, where most Afghans are European or Central Asian in appearance (the majority of Afghans belong to ethnic groups related to the ones that overran Europe thousands of years ago.) Afghans have been quick to turn in suspicious Arabs, or any suspected terrorist activities. So you have very few al Qaeda in Afghanistan, and few of them are Arabs.