Gray and grey are different spellings of the same word, and both are used throughout the English-speaking world. But gray is more common in American English, while grey is more common in all the other main varieties of English. In the U.K., for instance, grey appears about twenty times for every instance of gray. In the U.S. the ratio is reversed.
Both spellings, which have origins in the Old English grǽg, have existed hundreds of years.1 Grey gained ascendancy in all varieties of English in the early 18th century, but its dominance as the preferred form was checked when American writers adopted gray about a century later. As the Ngram below shows, this change in American English came around 1825. Since then, both forms have remained fairly common throughout the English-speaking world, but the favoring of gray in the U.S. and grey everywhere else has remained consistent.
Some people make their own distinctions between gray and grey. You can find some interesting examples in the comments below. There is nothing wrong with these preferences, but they are not borne out in broader usage. For most people, gray and grey are simply different spellings of the same word.
Both spellings are used for the participles, grayed/greyed and graying/greying, as well as for most of the words and phrases involving gray/grey. For instance, grey area/gray area, referring to an area having characteristics of two extremes, is commonly spelled both ways. So is graybeard/greybeard, referring to an older man with a beard, and gray squirrel/grey squirrel (which refer to closely related types of squirrels on opposite sides of the Atlantic). There are at least a couple of exceptions, though: greyhound, for the breed of dog, always has an e, while grayling, which refers to several types of fish, always has an a.