Balak had worked together with the Midianites to try to stop the people of Israel. Their plan of having Balaam put a curse on the Israelites didn’t work. So Balaam gave them advice about how to trick the Israelites.
Israelite men committed sexual sins with women from Moab and Midian. Then they started worshipping a false god named Baal with these women. These things were wrong and God brought judgement against his people for doing them. God sent a plague against them at the place called Baal Peor.
Phinehas showed how committed he was to making sure that the Israelites honoured God. Later God brought judgement against the Midianites for tricking God’s people. The Israelite army attacked them and destroyed their towns. Balaam was killed.
The plague at Baal Peor marked an important time. It was when all the Israelites who had refused to enter Canaan had died. After this the people were counted for a second time. They also received more instructions from God about making offerings and special promises. Joshua was set apart and recognised as the leader after Moses. He and Eleazar would lead the people like Moses and Aaron had.