The U.S. Treasury says it stands to lose $142 million in revenues this year because nonresident foreigners can legally avoid paying capital gains taxes on the sale of real estate in this country. Senate hearings begin June 25 on legislation that would close these tax loopholes.

A new Treasury report notes that foreigners have avoided paying capital gains taxes by installment sales, exchanges for foreign property of a like kind, and investments in tax havens. Most often, foreign investors create a holding company through which the gains on real estate are converted into gains on the sale of shares in the company, the Treasury Department said. Gains on the sale of shares in the holding company, which can be liquidated within one year, are not taxable under current law.

The Treasury gave this hypothetical example of a $1 million purchase of unimproved agricultural land:

The buyer puts $200,000 down, and obtains a 40-year mortgage at 10 percent. For 10 years the buyer rents out the land, pays the mortgage and taxes and ends up with a pre-tax cash out flow deficit of $42,000 a year.

At the end of the decade the property is sold for $2.9 million. The tax on the net proceeds of $2.1 million for a U.S. investor in the 60 percent bracket amounts to $343,000. Not only can be foreigner avoid taxes on capital gains, says the report, but he or she can use the annual losses to better advantage.

For example, if the real estate is held by a foreign-controlled U.S. corporation, the losses can be used to offset other U.S. income earned by the corporation. Or, a partnership agreement can be made between a foreigner and a U.S. resident in which all the capital gains go to the foreigner and all the losses to the resident. The net result is a higher rate of return than if each had invested separately.

The Treasury has calculated that if the capital gains on farmland held by nonresident aliens were taxed, $22 million in revenues would result. If commercial real estate were added, the total additional tax would be $142 million in 1979. This is based on the Office of Tax Analysis's assumption that $1.15 billion in assets will be sold and the tax as a percentage of sales value is 12.3 percent.

Foreigners are expected to purchase something under $5 billion in U.S. real estate in 1979, much of it financed by U.S. mortgage leaders. In the Treasury's opinion, a successful closing of the tax loophole will not endanger investment from abroad because foreigners are more concerned about economic and political uncertainties overseas than they are about slight decreases in return on investment on U.S. property.

A bill introduced by Sen. Malcolm Wallop (R-Wyo.) would require foreigners to pay capital gains taxes on the sale of farm and rural land. Sen. Dale Bumpers (D-Ark.) has sponsored legislation to close the foreign loophole for all real estate gains.

The Treasury Department study and proposed legislation have their origins in the controversy that developed several years ago over the increased and often anonymous acquisition of U.S. farmland by aliens. The law now requires these transactions to be registered and monitored by the government.