Then Satan stood up against Israel and moved David to number Israel. So David said to Joab and to the princes of the people, “Go, number Israel from Beersheba even to Dan, and bring me word that I may know their number.” Joab said, “May the LORD add to His people a hundred times as many as they are! But, my lord the king, are they not all my lord’s servants? Why does my lord seek this thing? Why should he be a cause of guilt to Israel?” Nevertheless, the king’s word prevailed against Joab. Therefore, Joab departed and went throughout all Israel, and came to Jerusalem. Joab gave the number of the census of all the people to David. And all Israel were 1,100,000 men who drew the sword; and Judah was 470,000 men who drew the sword. But he did not number Levi and Benjamin among them, for the king’s command was abhorrent to Joab.
God was displeased with this thing, so He struck Israel. David said to God, “I have sinned greatly, in that I have done this thing. But now, please take away the iniquity of Your servant, for I have done very foolishly.”
The LORD spoke to Gad, David’s seer, saying, “Go and speak to David, saying, ‘Thus says the LORD, “I offer you three things; choose for yourself one of them, which I will do to you.” ’ ” So Gad came to David and said to him, “Thus says the LORD, ‘Take for yourself either three years of famine, or three months to be swept away before your foes, while the sword of your enemies overtakes you, or else three days of the sword of the LORD, even pestilence in the land, and the angel of the LORD destroying throughout all the territory of Israel.’ Now, therefore, consider what answer I shall return to Him who sent me.” David said to Gad, “I am in great distress; please let me fall into the hand of the LORD, for His mercies are very great. But do not let me fall into the hand of man.”
So the LORD sent a pestilence on Israel; 70,000 men of Israel fell. And God sent an angel to Jerusalem to destroy it; but as he was about to destroy it, the LORD saw and was sorry over the calamity, and said to the destroying angel, “It is enough; now relax your hand.” And the angel of the LORD was standing by the threshing floor of Ornan the Jebusite. Then David lifted up his eyes and saw the angel of the LORD standing between earth and heaven, with his drawn sword in his hand stretched out over Jerusalem. Then David and the elders, covered with sackcloth, fell on their faces. David said to God, “Is it not I who commanded to count the people? Indeed, I am the one who has sinned and done very wickedly, but these sheep, what have they done? O LORD my God, please let Your hand be against me and my father’s household, but not against Your people that they should be plagued.”
Then the angel of the LORD commanded Gad to say to David, that David should go up and build an altar to the LORD on the threshing floor of Ornan the Jebusite. So David went up at the word of Gad, which he spoke in the name of the LORD. Now Ornan turned back and saw the angel, and his four sons who were with him hid themselves. And Ornan was threshing wheat. As David came to Ornan, Ornan looked and saw David, and went out from the threshing floor and prostrated himself before David with his face to the ground.