I am confused with the uses of ahí, allí, and allá.
It seems they are used according to different situations.
Could you please tell me what are the differences are and provide some examples?
As far as I know, there are no strong differences between those words, at least in spoken language. There might be tiny differences according to the dictionary, but here are a few examples of their use, at least uses I can think of:
Ahí and allí are basically the same, but ahí seems to be less used than allí (according to RAE, though I disagree). Both indicate a physical place.
Ahí está Juan.
El accidente ocurrió allí.
Por ahí is used to indicate a place that is close by, or a place that is undetermined altogether.
Voy a caminar por ahí is something like "I'm going for a walk around".
Por ahí se cuenta que... means "It is said (around) that...", or "It is being said here and there that...", implying that a rumor is being spread, but without compromising with an actual location where this might've happened.
On the other hand, allí indicates time, but ahí does not. That is the one difference between both words. I must say, however, that I have not heard that use much here in Chile. It might be common in other countries.
Allí fue el trabajo is the example in the dictionary. It means something like the job was back then, meaning a past time that should be clear from the context (the rest of the conversation).
Allá indicates some place that could be far from you and a bit undetermined at the same time.
Allá en Rusia: "there in Russia".
Allá lejos: "there, far away". Basically, you wouldn't say allí here, because, roughly speaking, you would use allí only when you refer to a place that you can point with your finger (allí en la colina: "there, over the hill").
Allá also indicates time, but a remote past only.
Allá en tiempo del Imperio Romano.
Allá en la prehistoria.
Finally, there are a couple of uses of allá that do not apply to allí and ahí:
El más allá means "the underworld", in the sense of "the world beyond", not necessarily with a connotation of punishment (as in "hell"). When people die they go to the "más allá", and this could be heaven, hell or some other place or reality depending of one's beliefs.
Allá tú means "have it your own way". For example, if two people are discussing a plan of action and one of them is absolutely determined to proceed in a specific manner, the other one might get tired of arguing and say allá tú, as in "I give up, have it your own way". Same with allá él, allá ella, allá ellos, allá ustedes/vosotros and allá usted.
This can be explained with the three grades of demonstratives and of verbal persons:
Primera persona: Esta cosa aquí está cerca de mí.
Segunda persona: Esa cosa ahí está cerca de ti.
Tercera persona: Aquella cosa allí está cerca de él (o de otra persona; o sea, ni de ti ni de mí).
The acá and allá versions are less precise. You might in English say over here or around there. Por acá is around here, por allá is over there somewhere. There is no *ahá version for euphonious reasons; people use por ahí to mean out there somewhere, as though it were the -á version of the middle (2ª persona) degree.
Just a little addition to the existing good answers:
I believe that both
acá both originally were used in a similar way to the English
hither respectively (i.e.
to there or
to here), but this is not longer strictly required in modern Spanish grammar, as in modern English.
allá is typically used to mean
over there, with a sense of remoteness beyond that of
allí. It should be noted however that
acá is used rather more rarely, and when it is, it still tends to retain its original meaning of