Landmark legislation, a captive breeding program, and habitat conservation have brought them back from the brink.