U.S. District Court Judge Alcee L. Hastings, the first federal judge to be a defendant in a criminal trial while in office, was acquitted today of charges that he solicited a $150,000 bribe from two brothers convicted in his court of racketeering.

Hastings hailed the jury's decision as "a favorable result in one of America's most unfair trials," a reference to his contention that the Reagan administration singled him out for prosecution because he is black and because of his rulings opposing the government's treatment of Haitian refugees here.

Prominent Washington attorney William A. Borders Jr., accused of conspiring with Hastings to solicit the bribe, was convicted last March on the same charges in a separate trial in Atlanta.

Borders was arrested after accepting what the government claimed was the final installment of an alleged bribe from undercover agents in the parking lot of the Twin Bridges Marriott in Arlington. Hastings, in Washington that day for a testimonial cruise for Borders, flew back to Miami.

Today's verdict marked a personal triumph for Hastings, 46, the first black named to the federal bench in Florida. Hastings conducted his own defense for most of the two-week trial in the same court where he has sat as judge since President Carter nominated him in 1979. Hastings successfully contended that Borders acted without his knowledge in accepting the money.

"I feel vindicated, and I think that in many respects this is a tremendous victory for so many people," Hastings said as he left the courthouse.

As well-wishers hugged and kissed him outside the courtroom, Hastings smiled and said, "Another day in the life of a poor country boy."

The judge reiterated his criticism of the Reagan administration tonight, insisting that if the government was unhappy with his conduct it should have tried to have him impeached and removed from office by Congress rather than trying to prosecute and convict him in criminal court.

He called the prosecutors "gunslingers who were sent to do a job. And they did an outstanding job presenting an inadequate case."

The judge also said that he "believed the system worked . . . . I fought the system as a lawyer, I became part of it as a judge and, now it's fought me. No other judge, alive or dead, has gone through anything like this before."

With the acquittal, Hastings is entitled to continue serving on the federal bench, and he vowed to do so.

"I think I'm going to be a much better judge than I ever have been," Hastings said. "And be assured, I'm going to be a judge for life."

He refused to resign during the proceedings, but has not been hearing cases since he was indicted in December, 1981. There was no indication when he would resume work.

Hastings was charged with joining Borders, the former president of the National Bar Association, an 8,000-member organization of black lawyers, in soliciting a bribe from two brothers convicted of racketeering in Hastings' court.

The indictment--for bribery, conspiracy and obstruction of justice--alleged that Hastings through Borders agreed to restore $845,000 in seized funds and reduce the two brothers' three-year prison terms in return for $150,000.

Borders was arrested by the FBI in the parking lot of the Twin Bridges Marriott after collecting what the government alleged was the final bribe payment, $125,000.

The Miami jury, however, apparently found too many reasons for doubt in the government's admittedly circumstantial case against Hastings. Prosecutors conceded that no one piece of evidence would convict the judge, but argued unsuccessfully that, taken as a whole, the evidence was sufficient for a guilty verdict.

Hastings' attorney and friend, Patricia Williams, used her closing argument Wednesday to attack the evidence piece by piece, concluding that the case was "riddled with reasonable doubt." She and Hastings maintained that Borders was working with without Hastings' knowledge.

The most direct piece of evidence for government attempts to link Hastings to the bribery scheme was an Oct. 15, 1981, telephone conversation between Hastings and Borders that was taped by an FBI wiretap. In it Hastings said:

"I've drafted all those ah, ah, letters, ah, for him, and everything's okay. The only thing I was concerned with was, did you hear if, ah, hear from him after we talked?"

Justice Department attorneys Reid Weingarten and Robert Richter contended that this was coded language in which Hastings was saying he had drafted an order restoring the brothers' seized funds and was inquiring whether Borders had heard from an FBI agent posing as Frank Romano, one of the convicted racketeers allegedly paying a bribe.

Hastings insisted, however, that the letters in question were going to authorities and friends in Columbia, S.C., on behalf of Hemphill Pride, a friend and fellow lawyer in trouble with the law. Hastings said he wrote the letters, but never sent them because he later thought it would be unethical as a judge to do so.

Hastings produced several draft letters to bolster his contention. The government charged that they were concocted after the indictment. But an FBI laboratory test failed to establish the date on which they were written, leaving what the jury of 10 whites and two blacks apparently considered a reasonable doubt about the key telephone conversation.