The court in the capital, Ankara, had recently ruled against promoting a teacher who wore an Islamic-style head scarf.
The attacker, who was detained and being interrogated by anti-terrorism police, reportedly chanted "Allahu Akbar," or "God is Greatest," as he fired his weapon, private NTV television reported, citing witnesses.
Tansel Colasan, deputy head of the administrative court, the Council of State, told reporters that the attacker was shouting "I am the soldier of God," and said he was carrying out the attack to protest against the court decision on head scarves.
"These attacks will never reach their goal"
Ahmet Sezer, Turkey's president
The judges, all from the same court chamber, had been severely criticised for a decision in February barring the promotion of an elementary school teacher who wore an Islamic-style head scarf outside work.
Ahmet Necdet Sezer, Turkey's president, said in a statement condemning the shootings: "This attack will go into the history of the republic as a dark stain."
"These attacks will never reach their goal," Sezer said, adding that the justice system would not be intimidated and would fulfil its duty with "loyalty to the secular and democratic republic."
The country's secular military also denounced the assault. "We condemn this vile attack with hate," a statement said.
Under Turkish law, women are not allowed to enter schools or other public buildings wearing head scarves, and the wives of ministers are excluded from government functions and formal state dinners if they wear them.
The attacker reportedly told police that he had shot the judges to protest agaist the court decision, private CNN-Turk television reported.
The attacker was carrying the ID of a lawyer, and police are investigating whether the ID belonged to him.
If confirmed that the attack was carried out as a protest, it could put the Islamic-rooted government in an uncomfortable position.
About 99% of Turks are Muslims.
The country's secular establishment, however, which includes the courts and the military, has sought for decades to restrict Islamic influence, which some political leaders view as an obstacle to Western-style modernisation.
The wife of the prime minister wears a head scarf, and his governing Justice and Development Party has made no secret of its desire to lift a ban on wearing head scarves in government buildings and universities.
"I hope those who still can't see where Turkey is being dragged, who refuse to see it, will take this as a warning,"
Deniz Baykal, chairman of the main opposition Republican People's Party
The government of Recep Tayyip Erdogan had condemned the court's decision, and pictures of the judges were printed in Islamic-oriented newspapers.
Deniz Baykal, chairman of the main opposition Republican People's Party, held Erdogan's government responsible for the attack.
"I hope those who still can't see where Turkey is being dragged, who refuse to see it, will take this as a warning," Baykal said.
"Unfortunately, blood has spilled into politics in Turkey. Turkey is being dragged into a very dangerous situation. Everybody should come to their senses."
Erdogan also condemned the attack, and said the culprit would be severely punished.
The military is also deeply uncomfortable with the government's position on the head scarf issue and what it sees as a creeping Islamisation of society.
Among those injured in Wednesday's shooting was the head of the court chamber, Mustafa Birden, who was wounded in the liver and the spleen.
Birden reportedly had received death threats recently, and the administrative court complained then that its members could become targets, CNN-Turk TV said.
Mustafa Yucel Ozbilgin, another judge, was in critical condition and undergoing surgery for a bullet wound to the head, which caused severe damage to the brain, Erdener said.
A sixth judge escaped the attack unharmed, having thrown himself onto the floor, reports said.