WASHINGTON — The CIA diligently helped Afghans who had served in agency-sponsored units, like the man accused of shooting two National Guard members in Washington, navigate the U.S. immigration system, according to former U.S. officials familiar with the process.

The CIA has not commented on the vetting process that brought the man, Rahmanullah Lakanwal, to the United States, and the former U.S. officials spoke on the condition of anonymity given the classified nature of CIA partner units. But the agency’s director, John Ratcliffe, has faulted the Joe Biden administration’s vetting of Lakanwal and said he “should have never been allowed to come here.” Lakanwal is accused of killing one of the National Guard members and critically wounding the other in the attack Wednesday, just blocks from the White House.

Lakanwal was granted asylum in April, during the Donald Trump administration, but it is not clear when the CIA might have offered its endorsement of him.

The CIA routinely wrote classified letters to add to immigration files to help members of its partner forces in Afghanistan win approval for asylum or parole claims, one of the officials said. U.S. officials believed that the Afghans who had worked with the agency would be in particular danger if they remained behind under a Taliban-run government. The CIA-backed units were responsible for the deaths and detention of Taliban leaders and fighters.

One former U.S. official said the agency was diligent in advocating the immigration cases of all the people it worked with, and had a dedicated team to help them settle in the United States.

The agency also kept extensive biometric data, including retinal scans, on Afghans who served in its units, information that helped identify its partners among the thousands of Afghans who fled the country, according to former officials.

To join the partner forces, at first called Counterterrorism Pursuit Teams and later Zero Units, Afghans needed to get current force members to vouch for them, putting the reputation of their tribe or family on the line. As Afghans moved up in rank, they continued to be vetted regularly. During the Afghanistan War, the CIA also conducted polygraphs on members of its partner units to identify potential Taliban allies or those with anti-American sentiments, former officials said.

That intense vetting process in Afghanistan — and the work the units did evacuating people to the Kabul International Airport after the regular army collapsed in the face of the Taliban takeover — gave the agency confidence that people who had fought in its units posed no danger to Americans.

Human rights groups frequently criticized the CIA-backed units, raising questions of their oversight, their use of force and the civilian casualties caused by their operations. But the CIA has defended its work, disputing the allegations against the units and arguing they were the best disciplined and most effective Afghan military force during the war.