I Chronicles - Chapter 21
Drawn Swords
David was seized by an improper desire to take a census of the nation, an act that is forbidden under normal circumstances. He instructed Yoav to carry it out. Yoav balked, but David would not be swayed. The census was taken and the results were reported back to David. (Again, the numbers differ from those reported in Samuel, and the commentators discuss who may or may not have been included.) Since Yoav thought - rightly so - that the census was a bad idea, he did the bare minimum necessary to fulfill the king's command, managing not to tally the Tribes of Levi and Benjamin.
Sure enough, G-d was not pleased with David's actions and He sent punishment in the form of a plague. (G-d actually offered David a choice of punishments: a three-year famine, a three-month siege or a three-day plague. David chose the plague, preferring to be punished directly by G-d than by humans.) 70,000 people died in the plague (no doubt rendering the results of the census pretty moot!). G-d decided enough was enough and He stopped His messenger of destruction by the threshing floor of Ornan the Jebusite. (In Samuel, he is called Aravna.)
David saw G-d's messenger standing between Heaven and Earth, with his sword drawn over Jerusalem. (That phrase may be familiar from the Passover Haggadah.) David prayed, "Oh, G-d, the error was mine - why punish the nation on my behalf?" G-d's messenger told David, through the prophet Gad, to erect an altar to G-d on Ornan's threshing floor, where the plague had stopped.
Ornan was no doubt surprised to have the king show up at his threshing floor - and he must have been staggered to see that an angel was with him! Though Ornan offered the threshing floor as a gift, David insisted on buying it at full price to build his altar. David paid 600 gold shekels. (The parallel text in Samuel says fifty silver shekels - that was just for the threshing floor and the oxen that David used as sacrifices. The full price disclosed here was for the entire piece of property, which we now know as the Temple mount.)
David offered his sacrifices, which G-d accepted with a heavenly fire. G-d spoke to His angel, who sheathed his sword. When David saw that G-d had responded favorably, he made it his practice to offer sacrifices at this location. Even though most of the vessels of the Mishkan (Tabernacle) were in Givon, David's choice was motivated by his experience with the angel and the sword.
Verse 13 ("David said to Gad: I am greatly distressed...") may seem familiar but somehow wrong. That's because this verse is essentially the same as (but not identical to) II Samuel 24:14, which is the first line of the Tachanun prayer (specifically the "short form" recited most days). It's really close, but no cigar.