So Moses cried out to the LORD, "What should I do with these people? They're almost ready to stone me!"
The LORD answered Moses, "Bring some of the leaders of Israel with you, and go to where the people can see you. Take the staff you used to strike the Nile River.
I'll be standing in front of you there by a rock at Mount Horeb. Strike the rock, and water will come out of it for the people to drink." Moses did this while the leaders of Israel watched him.
He named that place Massah [Testing] and Meribah [Complaining] because the Israelites complained and because they tested the LORD, asking, "Is the LORD with us or not?"
The Amalekites fought Israel at Rephidim.
Moses said to Joshua, "Choose some of our men. Then fight the Amalekites. Tomorrow I will stand on top of the hill. I will hold in my hand the staff God told me to take along."
Joshua did as Moses told him and fought the Amalekites, while Moses, Aaron, and Hur went to the top of the hill.
As long as Moses held up his hands, Israel would win, but as soon as he put his hands down, the Amalekites would start to win.
Eventually, Moses' hands felt heavy. So Aaron and Hur took a rock, put it under him, and he sat on it. Aaron held up one hand, and Hur held up the other. His hands remained steady until sunset.
So Joshua defeated the Amalekite army in battle.
The LORD said to Moses, "Write this reminder on a scroll, and make sure that Joshua hears it, too: I will completely erase any memory of the Amalekites from the earth."