LA PAZ, Bolivia — When NASA scientists were searching decades ago for an ideal food for long-term human space missions, they came across an Andean plant called quinoa. With an exceptional balance of amino acids, quinoa, they declared, is virtually unrivaled in the plant or animal kingdom for its life-sustaining nutrients.

But while Bolivians have lived off it for centuries, quinoa remained little more than a curiosity outside the Andes for years, found in health food shops and studied by researchers — until recently.

Now demand for quinoa (pronounced KEE-no-ah) is soaring in rich countries, as American and European consumers discover the “lost crop” of the Incas. The surge has helped raise farmers’ incomes here in one of the hemisphere’s poorest countries. But there has been a notable trade-off: Fewer Bolivians can now afford it, hastening their embrace of cheaper, processed foods and raising fears of malnutrition in a country that has long struggled with it.

The shift offers a glimpse into the consequences of rising global food prices and changing eating habits in both prosperous and developing nations. While quinoa prices have almost tripled over the past five years, Bolivia’s consumption of the staple fell 34 percent over the same period, according to the country’s agricultural ministry.