It is used to indicate a time in the past, often in conjunction with a time period, such as:
* Two weeks ago
* A year ago
* Long ago
While it might seem like an adverb, it functions as a preposition because it links a noun phrase (the time period) to a verb or adjective.