The attacker fled the scene on foot, and may still have the deputy's .45-caliber handgun, said Grays Harbor County Sheriff Rick Scott. The suspect remains at large, but detectives are close to identifying him, Scott said.
Grays Harbor Superior Court Judge Dave Edwards was stabbed in the neck and upper torso during the unprovoked attack.
The deputy, identified as Polly Davin, was shot in the shoulder with her own weapon and stabbed.
Both victims were treated at a local hospital and released several hours later.
Scott said the attack happened on the first floor of the courthouse after staffers reported seeing a "suspicious person" whom no one recognized wandering around the second floor of the building with a briefcase.
Deputy Davin responded to the scene and approached the man to ask him what his business was there. The man identified himself as "Michael Thomas," then attacked the deputy with a small knife or scissors.
"It all happened very quickly," said Edwards, adding commotion compelled him to rush into the hallway where he saw the knife-wielding man attacking the deputy.
"When I went to assist the deputy, he had a weapon in his hand, a knife or something. He was stabbing at her," Edwards said.
Edwards rushed to the deputy's aid, prompting her attacker to turn his attention to the judge. Edwards was stabbed in the neck before he managed to fight off the man.
As the deputy drew her weapon, a .45-caliber handgun, the attacker threw her to the ground, grabbed the gun and shot her.
Deputy Polly Davin (left) and Judge Dave Edwards (right)
"He got the gun away from the deputy and went, 'Pop, pop!' And turned to look at me, and went out of the courthouse with the gun in his hand," Edwards said.
The judge said he had never seen the man before. "He doesn't know me and I don't know him," Edwards said.
The attacker was last seen running south, taking with him the secret to his identity - along with his knife and the deputy's gun.
Police immediately fanned out through the small town of Montesano to search for him. He was described as a stocky male in his 20s who was "nicely dressed," with a blue shirt and black pants.
The search eventually focused on a home near Academy Street North and Spruce Avenue East in Montesano that is not far from the courthouse. Officers and a SWAT team stormed the residence after neighbors said someone ran quickly inside there after the shooting, but they found no one inside.
Officers also checked out other reports of suspicious activity in Montesano, population 4,000, but nothing came of them.
Later, officials said a man by the name of Michael Thomas was detained by officers in Thurston County, but it turned out not to be the suspect in the courthouse attack.
The man remains at large, and Scott said officers are tracking down all leads and tips. They have not confirmed his identity.
The attack comes a year after Edwards had joined a lawsuit to protest planned state budget cuts he said were making courthouses dangerous, in particular the building that was the site of the shooting. According to budget information from the county, the Superior Court budget had been cut from $733,320 in 2010 to $645,818 for 2012.
"Anyone can enter the courthouse carrying weapons," said the lawsuit, according to The Aberdeen Daily World newspaper. "Judicial staff is at risk from and has been forced to quell arguments between litigants in the courthouse."
The courthouse and all schools in the area were placed on lockdown after the attacks, then were lifted at about 3:15 p.m. The street in front of the courthouse also was closed down.
Officials said court was not in session at the time of the attack.
The courthouse, which is more than 100 years old, does not have metal detectors or surveillance cameras.
Anyone with information on Friday's shooting is urged to call the sheriff's office tipline at 360-249-3911 or the Crime Stoppers at 1-800-222-TIPS.