Four veteran District of Columbia judges announced their retirements yesterday from the Superior Court and the Court of Appeals in a last-minute to take advantage of two cost-of-living raises.

Appeals Court Judge George R. Gallagher, and Superior Court Judges William S. "Turk" Thompson, Leonard Braman and Fred L. McIntyre retired in order to collect a total of 12.1 percent in cost-of-living benefits on top of their regular pension benefits.

The retirements came at the last minute because the judges were not aware of the opportunity until late this week when they received memoranda from the city personnel department. l

"I didn't know I was going to retire till a couple of hours ago," said Thompson, 69, a pre-home rule D.C. City Council member who has served 11 years on the bench. "My wife doesn't even know." Thompson was also a member of the Joint Committee on Judicial Administration, a five-member committee which administraters the D.C. Court System.

Gallagher, 65, was one of the four appellate judges who last fall tried unsuccessfully to block the reappointment of Theodore R. Newman Jr. as chief judge. Gallagher has repeatedly told friends that the court had become more a "contest than a collegial atmosphere" and that he might retire after Newman's appointment. Gallagher had served 13 years on the bench and will receive 80 percent of his $64,000 annual salary plus the cost-of-living incrase, according to D.C. Personnel Director Jose Gutierrez.

Braman, 55, presided over the celebrated 1974 Hanafi Muslin murder trial in which five Black Muslims from Philadelphia were convicted of murdering seven Hanafi Muslims in 1973 at the Hanafi headquarters on 16th Street.

McIntyre, 61, who served with Thompson on the Joint Committee on Judicial Administration, served 14 years on the Superior Court. He previously had been chief counsel for the Senate District Committee and worked in the U.S. Attorney's office.

McIntyre, who has the lengthiest government service record, will receive 80 percent of his $60,000-a-year salary plus the cost-of-living increase. Thompson and Braman will receive 33 percent, plus the increase, Gutierrez said.

The retirements come at a time when the Superior Court already is understaffed with two vacancies -- that of late Edmund T. Daly, and Judge Norma H. Johnson, who was named by President Carter to the U.S. District Court. Carter had nominated two Washington lawyers to fill the judgeships, but President Reagan withdrew the names and has yet to submit new choices.

The D.C. Judicial Nomination Commission now must send to the White House the names of twelve candidates for the newly-vacated posts, and Reagan will have the opportunity of filling a total of six judgeships -- five on the 44-member Superior Court and one on the nine-judge appellate court.

Gallagher's retirement comes only several months after he and three other D.C. Court of Appeals judges attempted unsuccessfully to oust Newman as Chief Judge.

Although the retirements were filed yesterday, all four judges are expected to remain active until their successors are chosen, which could be up to six months.

Gutierrez said that by retiring yesterday the four judges were able to take advantage of two cost-of-living raises: a 4.4 per cent raise effective today; as well as a 7.7 per cent increase that was effective last September.