Both spellings stem from the Old English græg, both were used interchangeably until the 1700s, and both are correct. However, gray is standard in American English and grey in British English.
The distinction has two exceptions: grayling, a freshwater fish, is always spelled with an a, and greyhound, a dog breed (and bus company), is always spelled with an e. The former seems to be an American fish, though Australian and New Zealand graylings exist. The latter, greyhound, stems from the Old English grighund—grig (bitch) + hund (dog)—and is unrelated to the color except in popular imagination.