The Jewish penitential poems and prayers known as Selichot are said every day in the period leading up to the High Holidays, with the Thirteen Attributes of Mercy as a central theme throughout each daily recitation.
Here’s a funny thing: we don’t know how the Selichot have captured their central status in the month of Elul, the days between Rosh Hashanah and Yom Kippur, Yom Kippur itself, and other occasions. Jews may have assembled to beg for Divine mercy during the Second Temple period as well as the Talmudic period, but we have no clear evidence of it. The first Selichot we have were written in the 9th century in Italy and the 10th in Iraq. However, from the context of those Selichot poems, it appears that the authors considered them a common and familiar custom, and the siddur of Rabbi Saadia Gaon (10th century) refers to them as Chovat Hayom (duty of the day).
So some time between the decline of the Jewish center in Eretz Israel and the early Medieval era we started saying Selichot as part of our annual cycle of prayers.
As of the end of the Rishonim period (15th century), the custom of starting to say Selichot on the first day of Elul was accepted in the Sephardic and Yemenite communities. Selichot are not said on Rosh Chodesh Elul itself, but the closer we get to Rosh Hashanah, the more people get up for Selichot, and everybody says them between Rosh Hashanah and Yom Kippur, the “ten days of repentance.” Almost no one says Selichot on Rosh Hashanah.
The Ashkenazi custom is to start saying selichot on Saturday night that falls before Rosh Hashanah, provided it leaves four weekdays before Rosh Hashanah. In other words, if Rosh Hashanah falls on a Thursday or Shabbat, Ashkenazim start saying Selichot on Saturday night. But if Rosh Hashanah falls on a Monday or Tuesday, Selichot begins to be said on Saturday night the week before.