2 Samuel 24:17-25

17 Then David spoke to the LORD when he saw the angel who was smiting the people, and said, "Lo, I have sinned, and I have done wickedly; but these sheep, what have they done? Let thy hand, I pray thee, be against me and against my father's house."
18 And Gad came that day to David, and said to him, "Go up, rear an altar to the LORD on the threshing floor of Arau'nah the Jeb'usite."
19 So David went up at Gad's word, as the LORD commanded.
20 And when Arau'nah looked down, he saw the king and his servants coming on toward him; and Arau'nah went forth, and did obeisance to the king with his face to the ground.
21 And Arau'nah said, "Why has my lord the king come to his servant?" David said, "To buy the threshing floor of you, in order to build an altar to the LORD, that the plague may be averted from the people."
22 Then Arau'nah said to David, "Let my lord the king take and offer up what seems good to him; here are the oxen for the burnt offering, and the threshing sledges and the yokes of the oxen for the wood.
23 All this, O king, Arau'nah gives to the king." And Arau'nah said to the king, "The LORD your God accept you."
24 But the king said to Arau'nah, "No, but I will buy it of you for a price; I will not offer burnt offerings to the LORD my God which cost me nothing." So David bought the threshing floor and the oxen for fifty shekels of silver.
25 And David built there an altar to the LORD, and offered burnt offerings and peace offerings. So the LORD heeded supplications for the land, and the plague was averted from Israel.