Riggs National Corp., taking its first step across the District line, yesterday agreed to buy Guaranty Bank and Trust Co. of Fairfax for $37.8 million.

Although Guaranty is a small bank, with five branches and assets of $128 million compared with Riggs' $5.4 billion, its purchase is significant because it is the first move to the suburbs by a large District bank. Since the District, Maryland and Virginia passed reciprocal interstate banking legislation, virtually all of the activity has been by suburban institutions purchasing District banks.

As a result, Riggs -- Washington's largest bank -- is facing increased competition from such banks as Sovran Financial Corp. of Virginia, which recently purchased D.C. National Bancorp and Suburban Bancorp, and United Virginia Bankshares, which purchased NS&T Bankshares and has agreed to acquire Bethesda Bancorporation.

In addition, Citicorp of New York, the nation's largest bank holding company, is expected to buy National Permanent, the city's second-largest thrift institution. And 11 other companies are trying to take advantage of a loophole in banking laws by setting up limited-service banks in the District.

Riggs' agreement with Guaranty -- which is subject to approval by state and federal agencies and Guaranty's shareholders -- provides for the Virginia bank to be merged into a new national bank subsidiary of Riggs. The resulting bank probably will operate under the name Riggs National Bank of Virginia, according to the company.

Riggs is looking for other banks to acquire in the Washington suburbs, and is talking with several specific banks, said Riggs spokesman George Beveridge. He declined to name any of the banks.

"Clearly, this is Riggs' effort to remain competitive and maintain positions in those markets," said Eliot Benson, vice president of Ferris & Co., a Washington brokerage firm. "It's in line with management's earlier statements that they planned to remain independent and make acquisitions of their own."

In April, Riggs raised $60 million by selling stock in preparation for making acquisitions in Maryland and Virginia. That sale reduced the amount of stock held by Riggs Chairman Joe L. Albritton from 41 percent to 35 percent of the bank's outstanding shares.

"There are not a great many opportunities there at a reasonable price," said analyst Benson, who said he wondered whether Guaranty, at more than three times its book value, wasn't also a bit overpriced. However, he pointed out that it was so small, it would not be "a blip on Riggs' balance sheet," nor would it dilute earnings.

Analysts also agreed that the acquisition of the Virginia bank could make Riggs a more attractive takeover target, allowing it to command a higher price in the event of a takeover because it is already in two markets.

The jump across the Potomac by Riggs is a necessary move as the Virginia and Maryland suburbs grow at an ever faster clip and the old assumption that suburbanites come into the city to work and do business no longer holds, according to analysts.

As Riggs National Bank of Virginia, Guaranty's five branches will offer more services than they do now, such as larger loans and the probable addition of automatic teller machines, which they do not have now, Beveridge said.

Ernest M. Carter, who was a founder of Guaranty in 1964, will remain with the bank, as will other members of Guaranty's board of directors, according to the agreement. The $37.8 million purchase price will mean Guaranty stockholders will be paid $31.50 in cash for each share of outstanding common stock.

Riggs' stock closed yesterday at $39.25, up 25 cents.