SPOKANE, Wash. -- Court documents show the man who tied up police resources in a two and half hour standoff Tuesday was supposed to be working as a confidential informant for police.

During the standoff, police sent a robot into a home on Empire Avenue near Lidgerwood Street. Police even used tear gas before Juan Barragan came out and was taken into custody.

Court documents reveal Barragan was initially arrested on Sunday for unlawful possession of a firearm and possession of a methamphetamine and heroin. Documents said Barragan decided to cooperate with law enforcement to avoid federal charges.

Law enforcement officers arranged for him to be released from jail and in return he agreed to buy drugs from narcotics traffickers who were supposed to bring drugs to Spokane. This is a relatively common practice for police when they're trying to bust drug dealers and stop other illegal operations. Documents said police gave Barragan $6,000 in cash for the controlled drug deal and he was told to stay under police surveillance.

Documents said Barragan took off with the cash and fled to the home on Empire where the SWAT standoff ensued. Police got back the $6,000 in cash but Barragan is now facing theft charges. He is being held on $50,000 bond.