He stays at the middle of the two parties and he makes sure that both follow the rules of court.
The judge, like the referee, possesses independent judgment. In the same way as the referee studied the rules of basketball, the judge also studied the laws of the country in order for him to adjudicate wisely and independently. The judge hears the case, studies the evidences presented by the parties and then he independently judges who between the parties are telling the truth. The referee, on the other hand, looks while the players toss and shoot the ball without cheating by both teams. He ensures that the players obey the rules which are set forth. The referee makes sure that the winner deserves the trophy and the judge also makes sure that justice is upheld.
The judge knows when and how should the parties present their evidences. He gives both parties the chance to examine the witnesses and to provide rebuttals for certain testimonies without him doing any act of discrimination or pressure. This is also done by a referee. He knows when a team should be allowed a "free throw" and he checks whether the rebounds are done without hurting someone or else the corresponding consequence would be applied. The referee acts fairly without discriminating the other team by giving them more free throws even if they are not entitled to it. He gives both teams the chance to play and shoot the ball as long as they know their limitations.