Just because you can buy something abroad doesn't mean that Customs will allow you to bring it back into the country. Bringing in anything that is considered a narcotic is usually a big no-no. Not sure how Ambien is classified, so do your homework first.
Ambien is a non narcotic drug belonging to the Hypnotic-sedative drug group. Be careful buying it on the internet or maybe in other countries - some have been found to have a drug mixed in it called "Haldol" which is a psychiatric anti-psychotic drug. I work in the field so I am familiar with Ambien.
As I understand it, very few medications that require a prescription in the US can be obtained without a prescription in Mexico. That being said, you may be able to get a recommendation for a physician who will write a prescription for you. The cautions listed above should be taken seriously. It's much easier, safer and likely cheaper to just ask your regular physician at home to prescribe it. A generic form is now available that is quite inexpensive.