II Chronicles - Chapter 19
Ahab was killed in battle, but Yehoshafat returned safely to Jerusalem. Yehu, son of the prophet Chanani, went out to greet him. Yehu asked whether it was appropriate to befriend and assist enemies of G-d, meaning Ahab. G-d did not approve of this alliance, Yehu said, but Yehoshafat had a lot of merits, so G-d was willing to overlook it.
Yehoshafat remained in Jerusalem, occasionally going out among his subjects in other cities to bring them back to G-d and Torah. He set up judges throughout the land with the charge that they don't work for humans, but for G-d, meaning that they may not show any form of favoritism, but only administer law according to the Torah.
Yehoshafat also established the Sanhedrin, a court in Jerusalem to set the religious standard and to settle disputes. They were likewise instructed to cling to G-d in rendering their judgments. As the highest court in the land, they would decide on matters brought to them by the local courts of other cities. Amaryahu the kohein was placed in charge of religious matters and Zevadyahu of Judah was placed in charge of matters concerning the king.