Where does "mi querida" and "ay caray" come from and what does it mean in english?

The literal translation of the Spanish words "mi querida" is "my dear" and "ay caray" is "Oh, damn".
Updated on Wednesday, February 01 2012 at 07:27PM EST
Source: kgb.com