Previously a critic of James II, Williams entered the king's service in 1687, being appointed Solicitor General. He had been knighted two days previously, and in June 1688 he was created a baronet, of Gray's Inn in Middlesex. He held an important role in the prosecution of the Seven Bishops, but the violent antipathy between himself and the Lord Chief Justice, Sir Robert Wright, who accused him, with no relevance whatever to the issue before the Court, of taking bribes, probably contributed to the verdict of not guilty. Judge Jeffreys (the hanging judge) tried to ruin Williams with a fine for publishing a libel: this led to the pair engaging in a bitter personal and professional rivalry.