2 Samuel 24:2-15 New King James Version (NKJV)
2 So the king said to Joab the commander of the army who was with him, “Now go throughout all the tribes of Israel, from Dan to Beersheba, and count the people, that I may know the number of the people.”
3 And Joab said to the king, “Now may the Lord your God add to the people a hundred times more than there are, and may the eyes of my lord the king see it. But why does my lord the king desire this thing?” 4 Nevertheless the king’s word [a]prevailed against Joab and against the captains of the army. Therefore Joab and the captains of the army went out from the presence of the king to count the people of Israel.
5 And they crossed over the Jordan and camped in Aroer, on the right side of the town which is in the midst of the ravine of Gad, and toward Jazer. 6 Then they came to Gilead and to the land of Tahtim Hodshi; they came to Dan Jaan and around to Sidon; 7 and they came to the stronghold of Tyre and to all the cities of the Hivites and the Canaanites. Then they went out to South Judah as far as Beersheba. 8 So when they had gone through all the land, they came to Jerusalem at the end of nine months and twenty days. 9 Then Joab gave the sum of the number of the people to the king. And there were in Israel eight hundred thousand valiant men who drew the sword, and the men of Judah were five hundred thousand men.
The Judgment on David’s Sin
10 And David’s heart condemned him after he had numbered the people. So David said to the Lord, “I have sinned greatly in what I have done; but now, I pray, O Lord, take away the iniquity of Your servant, for I have done very foolishly.”
11 Now when David arose in the morning, the word of the Lord came to the prophet Gad, David’s seer, saying, 12 “Go and tell David, ‘Thus says the Lord: “I offer you three things; choose one of them for yourself, that I may do it to you.” ’ ” 13 So Gad came to David and told him; and he said to him, “Shall seven[b] years of famine come to you in your land? Or shall you flee three months before your enemies, while they pursue you? Or shall there be three days’ plague in your land? Now consider and see what answer I should take back to Him who sent me.”
14 And David said to Gad, “I am in great distress. Please let us fall into the hand of the Lord, for His mercies are great; but do not let me fall into the hand of man.”
15 So the Lord sent a plague upon Israel from the morning till the appointed time. From Dan to Beersheba seventy thousand men of the people died.