In Spain, the letter Y is pronounced like the English Y in "yes." In Latin America, it is quite different – learn more.
The only exception is when it’s the word y, meaning "and."
Please note that this explanation is only a guideline for the Spanish that I know, which is Castilian Spanish. There are many regional variations in Spanish pronunciation.