Updated

A CIA operative's unusual assignment inside the New York Police Department is being cut short after an internal investigation that criticized how the agency established its unprecedented collaboration with city police, The Associated Press has learned.

In its investigation, the CIA's inspector general faulted the agency for sending an officer to New York after the Sept. 11, 2001, terrorist attacks and leaving him there too long with haphazard oversight, according to officials who have read or been briefed on the inquiry. They spoke only on condition of anonymity because they weren't authorized to discuss the investigation. The CIA said last month that the inspector general cleared the agency of any wrongdoing.

The inspector general opened its investigation after a series of AP articles that revealed how the NYPD, working in close collaboration with the CIA, set up spying operations that put Muslim communities under scrutiny. Plainclothes officers known as "rakers" eavesdropped in businesses, and Muslims not suspected of any wrongdoing were put in intelligence databases.

The CIA officer cited by the inspector general for operating without sufficient supervision, Lawrence Sanchez, was the architect of spying programs that helped make the NYPD one of the nation's most aggressive domestic intelligence agencies. The programs have drawn criticism from Muslims as well as New York and Washington lawmakers. Muslim activists organized a news conference Thursday to urge Police Commissioner Ray Kelly to resign.

Sanchez, a CIA veteran who spent 15 years overseas in the former Soviet Union, South Asia and the Middle East, was sent to New York to help with information sharing following the 9/11 attacks. While on the CIA payroll from 2002 to 2004, he also helped create and direct police intelligence programs. He then formally joined the NYPD while on a leave of absence from the CIA.

The loosely defined assignment strained relations with the FBI and two consecutive CIA station chiefs in New York who complained that Sanchez's presence undermined their authority. U.S. officials have acknowledged that the rules were murky but they attributed that to the desperate push for better intelligence after the attacks.

Sanchez left the NYPD in 2010. Then, last July, the CIA sent one of its most senior clandestine operatives to work out of the NYPD. That's the officer who now is leaving. While the internal investigation found problems with the oversight of Sanchez's assignment, officials said the rules of the current arrangement were more clearly defined.

Even now, however, confusion remains.

Police Commissioner Kelly said the new officer was working at the NYPD to help share foreign intelligence. Federal officials, however, said he was there on a management sabbatical and was not sharing intelligence.

Kelly and the federal government also are at odds explaining the legal basis for a relationship between a local police department and the CIA, which is not allowed to spy domestically.

This fall, Kelly told the city council that the collaboration was authorized under a presidential order. But under those rules, the assignment would have had to have been approved by the CIA's top lawyer. The AP reported last week there was no such approval.

A CIA spokeswoman, Jennifer Youngblood, said Sanchez was sent to New York at the direction of then-CIA Director George Tenet, who had the authority to move his officers around the world to make sure intelligence was being shared. That arrangement did not require the lawyer's approval, she said.

"Context matters here," Youngblood said. "The CIA stepped up cooperation with law enforcement on counterterrorism after 9/11. It's hard to imagine that anyone is suggesting this was inappropriate or unexpected."

The current officer, whose name remains classified, operates under a more formal arrangement, specified in writing that he works directly for the NYPD. Nevertheless, some U.S. lawmakers have expressed concerns about the assignment, and the federal government's most senior intelligence official, Director of National Intelligence James Clapper, has acknowledged the arrangement looks bad and has said it would be addressed.

The CIA officer is working as a special assistant to David Cohen, the NYPD's top intelligence officer. Cohen did not respond to an email Thursday requesting comment.

It's unclear exactly when the CIA officer will leave the police department and what his next job will be. A former station chief in Pakistan and Jordan, he is one of the CIA's most experienced spies.

Kelly, the police commissioner, has defended his department and its Demographics Unit, which monitored conversations in cafes and wrote reports on Muslim businesses. Kelly has said his officers only follow leads. But internal police documents obtained by the AP show that even the most generic lead was used to justify surveillance of entire neighborhoods. Officials involved in the effort also told the AP that the Demographics Unit actually avoided locations where criminal investigations were under way for fear of disrupting them.

Relations between the NYPD and the Muslim community were further strained this week when police acknowledged that it showed nearly 1,500 officers a training video featuring Kelly. The video portrayed Muslims wanting to "infiltrate and dominate" the United States. Kelly apologized but only after police spokesman Paul Browne falsely claimed that the segment showing Kelly had been lifted from a previous interview. Browne later acknowledged that Kelly sat for an exclusive interview with the filmmakers and that Browne himself suggested it.