Meanwhile, at the Pentagon, Defense officials said that 3,000 Marines and soldiers were on the ground in Kabul as of Sunday night to help with the evacuation, and another 3,000 were en route.

Tension had been building between the Kabul Embassy and the Pentagon, the officials said, with Pentagon officials urging a smaller footprint and the State Department seeking to keep a robust presence. During meetings and video conference calls, Pentagon officials reminded their diplomatic counterparts that American troops were leaving.

Three weeks ago, as Afghan cities began to fall to the Taliban, Defense Secretary Lloyd J. Austin III extended the deployment of the amphibious assault warship U.S.S. Iwo Jima in the Gulf of Oman so that it would be close to the region. One week after that, he ordered the Marine expeditionary unit on the ship — some 2,000 Marines — to disembark and wait in Kuwait so that they could more easily deploy to Afghanistan.

On Sunday, the military evacuated 500 people, officials said, adding that they expected that number to go up to 5,000 a day in the coming week.

All U.S. embassies overseas have emergency evacuation plans, but Kabul posed significant hurdles. First, with some 4,000 employees, the embassy is one of the largest in the world. Shutting it down and destroying any sensitive documents and other materials takes time. Second, given that the Taliban control border crossings out of the country, the evacuation has to be done entirely by air, officials said.

Thousands of others, including dual citizens and U.S. contractors, are also in the country.

Embassy officials urged American citizens who are still in Afghanistan to shelter in place and resubmit paperwork to request help to leave instead of showing up at the airport, given reports of gunfire there.