The nation's biggest banks had $164.2 billion in loans outstanding to foreigners on June 30, 1977, according to a new study released yesterday by the three federal bank regulatory agencies.

Most of the loans were to developed countries, with Great Britain accounting for more than any nation. Government agencies, banks and other private borrowers in Great Britain had $25.1 billion in loans outstanding from U.S. banks.

Japan was next with $11.8 billion in loans from U.S. banks. Following closely were two developing countries that have borrowed heavily in recent years, in part to finance their large oil bills: Brazil and Mexico. Brazil has borrowed $10.6 billion and Mexico $11.3 billion from U.S. banks.

The study was conducted on an experiemental basis by the Comptroller of the Currency, the Federal Reserve Board and the Federal Deposit Insurance Corp. The three bank regulatory agencies have decided to publish the survey twice a year, starting with data available for December 1977.

The survey will come out about four months after the date the banks are required to report.

The survey covered 119 banks with assets of $1 billion or more. Although these banks are only a small percentage of the total of more than 14,000 banks, they do nearly all of the foreign lending in the country and their assets are more than half the nation's total banking assets.

The three agencies did not identify the 119 banks.

The information collected in the study covered loans made from a banks offices in one country to borrower (a cross-currency loan).

In a statement, the agencies said "cross-border and cross-currency loans are those most closely associated with country risk."

The agencies did not say whether the data indicated that U.S. banks as a whole were overexposed by their foreign lending, although government analysts said that the results of the survey contained no great "surprises."

However, some analysts have worried that countries such as Zaire, Peru, Turkey and Portugal may have trouble repaying some of their loans.

Of those countries, Turkey has $1.47 billion, or 0.9 per cent, of total U.S. lending; Portugal has $525 million, or 0.3 per cent; Zaire has $283 million, or 0.2 per cent; and Peru has loans totalling $1.9 billion from U.S. banks, or 1.2 per cent of the $164 billion outstanding.

Last week, Comptroller of the Currency John G. Heimann proposed a rule that would prohibit a bank from lending more than 10 per cent of its capital to a foreign government. The move is designed to keep U.S. multinational banks from overexposing themselves in their foreign operations.

Of the 164 billion in loans, 63 billion went to private, non-bank borrowers, $59 billion went to other banks and $42 billion went to governments or government agencies.

Major European countries, Japan and Canada accounted for $68.6 billion, or 42 per cent, of total lending. Another 20 per cent, or $33.8 billion, was loaned to other developing countries or to so-called offshore banking centers such as the Bahamas or the Caymans, where major multinational banks conduct international money market operations.

Non-oil developed countries, presumably among the riskiest borrowers, had loans of about $40 billion, or 24 per cent.

Oil-exporting countries had $12.2 billion in loans, Communist loans totalled $6 billion and "miscellaneous" loans were $3.5 billion.

About 63 per cent of the loans had a maturity of one year or less. In the major developed countries and the off-shore banking centers, $64 billion of the $85 billion in loans had short-term maturities, reflecting the heavy volume of very short, often overnight, inter-bank lending.

In other countries, about half of the loans were for less than a year and the other half were for more than a year.