In Shoftim (Deut 17:14), it is said that Israel will ask for a King to rule over it once it is settled in the land. The Artscroll Stone Edition Tanakh does not list the specific source for this, but it says that Israel was commanded to do three things once it settled in the land, the first being the choosing of a King. So it views this verse as a commandment.
In I Samuel 10:19, G-d criticizes Israel's decision to ask for a King. He says that through this act they are rejecting Him.
Why would Israel be criticized for doing what they were commanded to do?
I've heard the opinion that the section in Shoftim about the King is not a commandment, but a statement of a future event. The purpose of which is to tell Israel not to choose a Gentile King, but a brother to rule over them.
So how should these seemingly contradictory events be interpreted?