The expulsions come amid a disagreement on whether to include Taliban officials in talks aimed at getting them to put down their arms.
The senior UN diplomat, who works for the UN Assistance Mission in Afghanistan, and the acting head of the EU mission in Afghanistan were complying with an order to leave within 48 hours after the government said their actions posed a threat to Afghanistan's national security.
The men -- identified by news agencies as Briton Michael Semple and Irishman Mervin Patterson -- had been declared persona non grata.
The diplomatic row begun when the pair was detained on December 24 in Helmand Province, Afghanistan's main opium-producing region and the heartland of the insurgency.
Asadullah Wafa, the governor of the volatile province, said in Helmand that the men were detained along with at least two Afghans. "According to our information, among the people [Semple] met there are some people who support the government, but he met those who currently lead the groups of suicide bombers and they are the source of all the conflict in Helmand," Wafa said. "I, as the representative of the government, will not allow any foreigner to interfere in our political affairs."
Both the United Nations and the European Union have denied the accusation and insisted that they hope the misunderstanding behind the expulsions "will be resolved soon."
Neelab Mubarez, a spokeswoman for the UN office in Kabul, told RFE/RL's Radio Free Afghanistan that the men went to the Musa Qala district of Helmand to assess the humanitarian situation. Musa Qala was recaptured by Afghan and international forces from Taliban control that had been imposed since February. Neelab said the diplomats had spoken to local people and tribal leaders.
"When the military operation finished in Musa Qala, the diplomats went there to perform our main duties -- which are helping to strengthen peace and stability, and providing humanitarian assistance," Mubarez said. "They wanted to talk to people. The Afghan officials were aware of the diplomats' trip before they traveled to the area."
The Afghan central government has in the past tended to avoid official references to the Taliban when reporting violence, preferring to use the term "enemies of Afghanistan." What most observers describe as the Taliban comprises many different people and groups, and in a tribal area such as Helmand it can be difficult to distinguish between the various insurgent forces.
Attempts to negotiate in such conditions are complicated by the serious disagreement within Afghanistan and between Afghan President Hamid Karzai and western leaders over whether such talks with Taliban-like insurgents are desirable.
The government is predominantly made up of former members from the United Front (aka Northern Alliance), the former armed opposition to the Taliban regime before it was overthrown in 2001. Those former United Front members refuse to give Taliban insurgents a share of power and are against even talking to them.
One Western source said the incident showed there are "divisions within the government itself as to who we should and shouldn't be talking to."
The UN's Neelab said the organization hopes its diplomat will be able to return to Afghanistan once the "misunderstanding" is resolved.
Both Semple and Patterson are known as experienced experts on Afghanistan with broad knowledge of the tribal culture and local languages. The two men have reportedly lived in Afghanistan for more than 10 years, even during Taliban rule.
But Afghan officials have stood by the expulsions. Afghan Foreign Ministry spokesman Sultan Ahmad Beheen said that while the government needs and appreciates the international community's assistance, it must require foreign nationals in Afghanistan to obey the country's laws. "In every action the Afghan government has taken so far or is going to take [in regard to the diplomats], it was acting on the basis of Afghanistan's national and security interests," Beheen said.
Both the Afghan government and its international allies publicly insist that they do not negotiate with the Taliban. However, some Afghan officials have reportedly voiced increasing interest in meeting with the militant group's leaders to try to persuade them to end the insurgency.
President Hamid Karzai has publicly stated his willingness to negotiate with Mullah Omar, the Taliban leader, and Gulbuddin Hekmatyar, the radical Islamist warlord.
(RFE/RL's Radio Free Afghanistan contributed to this report)