The attack comes just days after the gang rape and murder of two minor girls in Badaun that has caused a nationwide furore.
The woman judge was found unconscious in her official residence Monday. She was drugged and badly injured.
Senior Superintendent of Police (SSP) Nitin Tiwari told IANS that based on the complaint of the victim's brother, a case of rape has been registered.
"As of now no medical has been conducted and we are waiting for the victim to be in a position to testify," he added.
Officials told IANS that a half-empty bottle of pesticide was also recovered at the crime scene and it is feared that after raping the judge, the assailants force fed her pesticide.
The woman judge has since been admitted to a hospital where her condition continues to be serious.
After a complaint was lodged by the brother of the victim at the Civil Lines police station, police lodged an FIR and are on a lookout for the assailants, officials said.