The way God deals with Pharaoh, ruler of Egypt, when the Israelites come out of Egypt, shows how God deals with rulers who oppose him.
Initially, God sends Moses to tell Pharaoh what he wants and we see Pharaoh's reaction:
1 Afterward Moses and Aaron came, and said to Pharaoh, “This is what the LORD, the God of Israel, says, ‘Let my people go, that they may hold a feast to me in the wilderness.’ ”
2 Pharaoh said, “Who is the LORD, that I should listen to his voice to let Israel go? I don’t know the LORD, and moreover I will not let Israel go.”
The LORD makes it clear at the start what is going to happen:
3 I will harden Pharaoh’s heart, and multiply my signs and my wonders in the land of Egypt. 4 But Pharaoh will not listen to you, so I will lay my hand on Egypt, and bring out my armies, my people the children of Israel, out of the land of Egypt by great judgements. 5 The Egyptians shall know that I am the LORD when I stretch out my hand on Egypt, and bring the children of Israel out from amongst them.”
Moses is sent to show Pharaoh a miracle that the Egyptians are able to copy. However God shows that he is in control when Aaron's rod swallows the Egyptians' rods:
10 Moses and Aaron went in to Pharaoh, and they did so, as the LORD had commanded. Aaron cast down his rod before Pharaoh and before his servants, and it became a serpent. 11 Then Pharaoh also called for the wise men and the sorcerers. They also, the magicians of Egypt, did the same thing with their enchantments. 12 For they each cast down their rods, and they became serpents; but Aaron’s rod swallowed up their rods.
At the plague of lice, Pharaoh's magicians are unable to copy Moses' sign and they tell Pharaoh that this is supernatural:
18 The magicians tried with their enchantments to produce lice, but they couldn’t. There were lice on man, and on animal. 19 Then the magicians said to Pharaoh, “This is God’s finger;” but Pharaoh’s heart was hardened, and he didn’t listen to them, as the LORD had spoken.
At the plague of boils, the magicians themselves are personally affected. This time the LORD hardens Pharaoh's heart:
11 The magicians couldn’t stand before Moses because of the boils; for the boils were on the magicians and on all the Egyptians. 12 The LORD hardened the heart of Pharaoh, and he didn’t listen to them, as the LORD had spoken to Moses.
At the plague of hail, Egyptians who believe what Moses says can escape the effects by taking action themselves:
20 Those who feared the LORD’s word amongst the servants of Pharaoh made their servants and their livestock flee into the houses. 21 Whoever didn’t respect the LORD’s word left his servants and his livestock in the field.
When Pharaoh himself is personally affected by the death of his firstborn, he tells the Israelites to go and asks Moses to bless him!:
30 Pharaoh rose up in the night, he, and all his servants, and all the Egyptians; and there was a great cry in Egypt, for there was not a house where there was not one dead. 31 He called for Moses and Aaron by night, and said, “Rise up, get out from amongst my people, both you and the children of Israel; and go, serve the LORD, as you have said! 32 Take both your flocks and your herds, as you have said, and be gone; and bless me also!”