Satan wanted to bring trouble on the people of Israel, so he made David decide to take a census.
David gave orders to Joab and the other officers, "Go through Israel, from one end of the country to the other, and count the people. I want to know how many there are."
Joab answered, "May the Lord make the people of Israel a hundred times more numerous than they are now! Your Majesty, they are all your servants. Why do you want to do this and make the whole nation guilty?"
But the king made Joab obey the order. Joab went out, traveled through the whole country of Israel, and then returned to Jerusalem.
He reported to King David the total number of men capable of military service: 1,100,000 in Israel and 470,000 in Judah.
Because Joab disapproved of the king's command, he did not take any census of the tribes of Levi and Benjamin.
God was displeased with what had been done, so he punished Israel.
David said to God, "I have committed a terrible sin in doing this! Please forgive me. I have acted foolishly."
Then the Lord said to Gad, David's prophet,
"Go and tell David that I am giving him three choices. I will do whichever he chooses."
Gad went to David, told him what the Lord had said, and asked, "Which is it to be?
Three years of famine? Or three months of running away from the armies of your enemies? Or three days during which the Lord attacks you with his sword and sends an epidemic on your land, using his angel to bring death throughout Israel? What answer shall I give the Lord?"
David replied to Gad, "I am in a desperate situation! But I don't want to be punished by people. Let the Lord himself be the one to punish me, because he is merciful."
So the Lord sent an epidemic on the people of Israel, and seventy thousand of them died.
Then he sent an angel to destroy Jerusalem, but he changed his mind and said to the angel, "Stop! That's enough!" The angel was standing by the threshing place of Araunah, a Jebusite.
David saw the angel standing in midair, holding his sword in his hand, ready to destroy Jerusalem. Then David and the leaders of the people - all of whom were wearing sackcloth - bowed low, with their faces touching the ground.
David prayed, "O God, I am the one who did wrong. I am the one who ordered the census. What have these poor people done? Lord, my God, punish me and my family, and spare your people."
The angel of the Lord told Gad to command David to go and build an altar to the Lord at Araunah's threshing place.
David obeyed the Lord's command and went, as Gad had told him to.
There at the threshing place Araunah and his four sons were threshing wheat, and when they saw the angel, the sons ran and hid.
As soon as Araunah saw King David approaching, he left the threshing place and bowed low, with his face touching the ground.
David said to him, "Sell me your threshing place, so that I can build an altar to the Lord, to stop the epidemic. I'll give you the full price."
"Take it, Your Majesty," Araunah said, "and do whatever you wish. Here are these oxen to burn as an offering on the altar, and here are the threshing boards to use as fuel, and wheat to give as an offering. I give it all to you."
But the king answered, "No, I will pay you the full price. I will not give as an offering to the Lord something that belongs to you, something that costs me nothing."
And he paid Araunah six hundred gold coins for the threshing place.
He built an altar to the Lord there and offered burnt offerings and fellowship offerings. He prayed, and the Lord answered him by sending fire from heaven to burn the sacrifices on the altar.
The Lord told the angel to put his sword away, and the angel obeyed.
David saw by this that the Lord had answered his prayer, so he offered sacrifices on the altar at Araunah's threshing place.
The Tent of the Lord's presence which Moses had made in the wilderness, and the altar on which sacrifices were burned were still at the place of worship at Gibeon at this time;
but David was not able to go there to worship God, because he was afraid of the sword of the Lord's angel.