Once headed for the industrial junk heap, Hyundai drove itself back from the brink by learning three little words: quality, quality, quality.

J.D. Power III can still vividly recall his eye-opening maiden visit to a Hyundai plant in Seoul, South Korea, back in the mid-1970s.

"In their plant, they had people digging ditches - in dirt floors," recalls Power, the guru of American automotive tastes. The trenching work was all part of the plant's hurried efforts to finish construction work. Even without a completed foundation, though, "they were building vehicles." Not only was the assembly line operating in jury-rigged disarray, but Hyundai's suppliers were shipping second-rate parts. And the cars they were turning out quickly earned a reputation as the very worst the automotive industry had to offer.

Power's one-word description of the cars they were producing?

"Dangerous."

When they weren't being laughed out of the U.S. market, Hyundai cars were racking up some of the worst quality ratings Power had ever seen. And fleets of American consumers predictably avoided the ugly little vehicles.

Twenty years later, Hyundai was making better cars, but the company was still dogged by a reputation for shoddy engineering and mechanical failure. In the minds of consumers, Hyundai was a fourth-rate player, trailing well behind American muscle, European style, and Japanese performance.

But after years mired at the back of the automotive pack, Hyundai started to break out. Starting in the late 1990s, top management invested huge sums in new technology. Executives hired J.D. Power and ­Associates, the marketing firm best known for its car ratings, to tell the company what it needed to do to shed its broken-down image and go head-to-head with the Japanese automakers that had won the admiration of drivers worldwide.