1 Chronicles 21:16-19
21:16 David looked up and saw the Lord’s messenger standing between the earth and sky with his sword drawn and in his hand, stretched out over Jerusalem. David and the leaders, covered with sackcloth, threw themselves down with their faces to the ground.
21:17 David said to God, “Was I not the one who decided to number the army? I am the one who sinned and committed this awful deed! As for these sheep – what have they done? O Lord my God, attack me and my family, but remove the plague from your people!”
21:18 So the Lord’s messenger told Gad to instruct David to go up and build an altar for the Lord on the threshing floor of Ornan the Jebusite.
21:19 So David went up as Gad instructed him to do in the name of the Lord.