A federal judge has ordered Agriculture Secretary John R. Block to pony up as much as $600 million in federally insured loans to farmers under a program authorized by Congress in 1978.

U.S. District Court Judge Thomas A. Flannery, acting on a class-action suit brought by farmers across the country, ruled last week that Block's decision to withhold the funds was "arbitrary, capricious and an abuse of his discretion."

Flannery asked the lawyers representing the farmers to prepare an order requiring Block to disburse funds appropriated for fiscal 1982 under the Emergency Agricultural Credit Adjustment Act.

William R. King, an Atlanta lawyer who represents the farmers, said that Block had elected to cut off the loans at a time when farmers are faced with "the worst economic squeeze since the Depression."

As a result of the decision, King said, "a lot of farmers have gone down the tube."

Neil H. Koslowe, a Justice Department attorney, said he is reviewing the judge's ruling.

Under the program, farmers may obtain federally insured loans during times of economic distress if they cannot get loans elsewhere. In January, 1981, Block told Congress the loan program was no longer needed because farmers could obtain loans from uninsured, private sources. In any case, existing federal loan programs could be augmented if necessary, he said.

Later that year, Congress extended the loan program anyway. However, a Senate-House conference committee gave the secretary "broad authority" to determine the scope of the program, which the committee report described as "discretionary in nature," Flannery said.

"The discretion enjoyed by the secretary is not, however, unbounded," Flannery said, and he found unpersuasive the evidence submitted by the department to show that there was no need for the loans.

Throughout 1982, Block "received reports of growing numbers of delinquent loans and foreclosures," Flannery said. " . . . There is no evidence in the record to support the secretary's decision."