The LORD burned with anger against Israel again, and he incited David against them: Go and count the people of Israel and Judah.
So the king said to Joab and the military commanders who were with him, "Go throughout all the tribes of Israel, from Dan to Beer-sheba, and take a census of the people so I know how many people there are."
Joab said to the king, "May the LORD your God increase the number of people a hundred times while the eyes of my master the king can still see it! But why does my master the king want to do this?"
But the king's word overruled Joab and the military commanders. So Joab and the commanders left the king's presence to take a census of the Israelites.
They crossed the Jordan River and began from Aroer and from the town that is in the middle of the valley of Gad, then on to Jazer.
They continued to Gilead and on to Kadesh in Hittite territory. They came to Dan and went around to Sidon.
They went to the fortress of Tyre and to all the towns of the Hivites and the Canaanites. They went out to Beer-sheba in the arid southern plain of Judah.
At the end of nine months and twenty days, after going through the entire country, they came back to Jerusalem.
Joab reported to the king the number of the people who had been counted: in Israel there were eight hundred thousand strong men who could handle a sword; in Judah the total was five hundred thousand men.
But after this David felt terrible that he had counted the people. David said to the LORD, "I have sinned greatly in what I have done. Now, LORD, please take away the guilt of your servant because I have done something very foolish."
When David got up the next morning, the LORD's word came to the prophet Gad, David's seer:
Go and tell David, This is what the LORD says: I'm offering you three punishments. Choose one of them, and that is what I will do to you.
So Gad went to David and said to him, "Will three years of famine come on your land? Or will you run from your enemies for three months while they chase you? Or will there be three days of plague in your land? Decide now what answer I should take back to the one who sent me."
"I'm in deep trouble," David said to Gad. "Let's fall into the LORD's hands because his mercy is great, but don't let me fall into human hands."
So the LORD sent a plague on Israel from that very morning until the allotted time. Seventy thousand people died, from Dan to Beer-sheba.
But when the divine messenger stretched out his hand to destroy Jerusalem, the LORD regretted doing this disaster and said to the messenger who was destroying the people, "That's enough! Withdraw your hand." At that time the LORD's messenger was by the threshing floor of Araunah from Jebus.
When David saw the messenger who was striking down the people, he said, "I'm the one who sinned! I'm the one who has done wrong. But these sheep—what have they done wrong? Turn your hand against me and my household."
That same day Gad came to David and told him, "Go up and build an altar to the LORD on the threshing floor of Araunah from Jebus."
So David went up, following Gad's instructions, just as the LORD had commanded.
Araunah looked up and saw the king and his servants approaching him. Araunah rushed out and bowed low before the king, his nose to the ground.
Araunah said, "Why has my master and king come to his servant?" David said, "To buy this threshing floor from you to build an altar to the LORD, so the plague among the people may come to an end."
Then Araunah said to David, "Take it for yourself, and may my master the king do what he thinks is best. Here are oxen for the entirely burned offering, and here are threshing boards and oxen yokes for wood.
All this, Your Majesty, Araunah gives to the king." Then he added, "May the LORD your God respond favorably to you!"
"No," the king said to Araunah. "I will buy them from you at a fair price. I won't offer up to the LORD my God entirely burned offerings that cost me nothing." So David bought the threshing floor and the oxen for fifty shekels of silver.
David built an altar there for the LORD and offered entirely burned offerings and well-being sacrifices. The LORD responded to the prayers for the land, and the plague against Israel came to an end.