When Libya announced plans last year for what may be the largest civil engineering project in history, a $3.3 billion, 1,200-mile waterway, it came as no surprise that a South Korean company was selected to build it.

Since the early 1970s, hundreds of thousands of Korean hard hats have labored in the Middle East to transform sand and petroleum dollars into highways, ports, industrial plants and housing complexes.

Seoul's aggressive building companies have captured a staggering $65 billion in Middle East contracts, more than $40 billion of them in Saudi Arabia alone. It is South Korea's largest single source of foreign exchange.

But today the industry is in serious trouble. Declining new orders, intense competition, payments disputes and sometimes slipshod workmanship and management have pushed some of the companies to the edge of bankruptcy.

Officials in Seoul are worried. The companies' earnings are crucial to South Korea's own ambitious development plans. And their image as master builders and desert tamers are crucial to South Korea's good standing among Arab governments.

Although it is trying to diversify its sources, South Korea still buys about two-thirds of its oil from the Middle East. The value it puts on good will in the region also was demonstrated several years ago when it cut off relations with Israel.

In recent months, the Seoul government has begun reorganizing the industry, sometimes by force. It has arranged takeovers for at least four companies near bankruptcy and tightened standards that companies must meet to go overseas.

"We have to honor the commitments made by Korean companies abroad," said Lee Jong Ryool, information and analysis chief at South Korea's ruling Democratic Justice Party. "Government has ultimate responsibility."

South Korea's headlong rush into the world's construction markets tells the story of its approach to economic development as a whole. At times, enthusiasm overruled good sense and painful contractions followed. But in the end, more was accomplished than anyone had thought possible.

Industry officials date the start of their rush to 1965, when a Korean company won rights to build a highway in southern Thailand. From there, the Koreans moved into military construction for U.S. forces in South Vietnam.

Things took off with the oil shock of 1973. South Koreans quickly showed up in Middle East capitals where officials were mapping out vast public building programs but had hardly any labor or technical know-how of their own.

Low wages and a proverbial taste for hard work -- employes live in spartan desert camps, get only two days off a month and send 80 percent of their wages home -- explain much of the Koreans' success. Cut-rate government financing, currently $1 billion a year from the Korean Export-Import Bank, also has helped.

Shooting for volume, many companies were willing to accept razor-thin profit margins.

In 1976, Hyundai Construction & Engineering Co. began a billion-dollar port construction contract at Jubail, Saudi Arabia, amid talk that this time the Koreans had taken on more than they could handle. But Hyundai finished it and made money on it, too.

The Koreans have shunned Israel, but otherwise pay little attention to politics. They work on both sides of the Iran-Iraq battle lines. They work in Libya, despite its tense relations with South Korea's ally, the United States. They work in Libya's enemy, Egypt.

They have built the mechanical insides of comparatively simple industrial plants such as cement factories, but generally their forte is bricks, mortar and excavation. U.S., Japanese and Western European firms have taken most of the complex design and engineering work.

The jobs have created tremendous employment -- there are now about 147,000 South Koreans toiling in the Middle East. They also have led to major orders for Korean export industries producing such things as cement, steel and construction equipment.

But in the early 1980s, the bubble began to burst. New contracts won by Koreans peaked at $13.6 billion in 1981. They fell to $13.3 billion in 1982 and $10.4 billion in 1983. The Libyan waterway contract, awarded to Dong Ah Construction Industrial Co., slowed, but did not stop, the slide.

Cutbacks in Saudi building plans caused by the decline in oil prices were partly to blame. But competition from companies from such countries as India and Pakistan, which could underbid the Koreans on labor costs, also was a factor.

"Even Brazilians are coming in," lamented Suh Man Suk, executive vice president at Daewoo Corp., which is working its way through $2 billion in contract backlogs in Libya. Its projects there include 13,000 units of housing and 2,500 classrooms.

In addition, the Saudis and other petroleum-exporting countries have established infant construction industries of their own and are reserving much of the work for them.

Meanwhile, client countries have tightened payment terms and created special conditions. Libya, for instance, forced some companies to take oil as payment. This meant that they had to become brokers, which in today's buyer's market is not always profitable.

War drained the coffers in Iran and Iraq. Hyundai suffered heavily as Iraq cancelled nonstrategic projects and fell behind in payments for ones in progress. Iran, in contrast, has paid punctually. (Characteristically, the Koreans are talking about big business in repairing the damage of the Gulf war.)

Disputes helped push delayed payments to an officially estimated $1 billion. Unreasonable demands and footdragging ruses from client governments were at the root of many disputes, the Koreans contend.

For instance, Koreans say the Saudis recently refused to make the final payment on a completed housing development until separate elevators were installed for women, although the design called for none and there was no practical way to add them.

Still, executives concede that many problems were of the companies' own making. In the rush to get established, some bid dangerously low, then couldn't finish the job or ran out of cash. They acknowledge that some of the workmanship was substandard.

Today, the Koreans are trying to adjust to the new conditions. They are examining countries outside the Middle East, which now only accounts for about 15 percent of their work.

The Seoul government, meanwhile, has allowed them to recruit more workers outside Korea to save on labor costs. The government has stepped up public building at home, expanded credits for financially healthy companies and allowed them more flexibility in raising money overseas.

In the long term, Koreans talk about entering the more lucrative design and engineering field. But they are finding that developing those skills takes years. For the present, they are likely to stay centered in construction, where there is still billions of dollars worth of work to be done.