Roy M. Cohn, 59, a highly controversial New York trial attorney who rose to fame in the 1950s as the brilliant and pugnacious chief aide to Sen. Joseph McCarthy (R-Wis.) during his investigations of alleged communist subversion, died yesterday at the clinic of the National Institutes of Health.

Irene Haske, an NIH spokeswoman, said the primary cause of Mr. Cohn's death was cardiopulmonary arrest, and she listed dementia and "underlying HTLV III infections" as secondary causes. The HTLV III virus is the cause of acquired immune deficiency syndrome.

Mr. Cohn had repeatedly denied that he had AIDS, saying that he was suffering from liver cancer. Haske refused to elaborate on Mr. Cohn's illness, saying that she could release only information recorded on the public death certificate.

Commenting on Mr. Cohn's death, White House assistant press secretary Mark Weinberg said, "The Reagans are saddened and extend their sympathy to his family."

Mr. Cohn's career was remarkable for its length in the public eye and for the controversy that it generated. Whether he was investigating communist subversion in the 1950s, defending New York mob figures in the 1960s and 1970s or unsuccessfully fighting his own disbarment in New York this year, two constants remained in evidence throughout his life: high intelligence and savage intensity in adversity.

He was a member of the prosecution team that secured the convictions of Ethel and Julius Rosenberg on charges of passing atomic secrets to the Soviet Union. After joining McCarthy, he gained fame by questioning, sneering at and intimidating high-ranking government officials at what became known as the "McCarthy hearings." He also made headlines in struggles with the State and Army departments.

A generation of Americans remembers McCarthy, Mr. Cohn and another young investigator, G. David Schine, as among the country's first television personalities. McCarthy was a brooding, hulking figure, always ready to badger a witness. Mr. Cohn, with his slick hair, dark complexion and heavy-lidded eyes, was frequently seen whispering in the senator's ear.

Mr. Cohn and Schine made a highly publicized tour of Euorope in which they investigated alleged communist influence in the State Department and allegedly communist books in U.S. Information Agency libraries. The trip was ridiculed abroad and viewed with skepticism here.

Many remember the era as a time when Mr. Cohn and McCarthy destroyed the reputations and careers of people whom they tarred as communists or communist sympathizers, often through the use of innuendo or guilt by association.

Ironically, the downfall of McCarthy may be attributed to Mr. Cohn and Schine. When Schine was drafted, Mr. Cohn threatened to "wreck" the Army if Schine did not receive special privileges. The 1954 Army-McCarthy hearings ended in defeat for McCarthy and Mr. Cohn, who were bested by the Army's suave counsel, Joseph N. Welch. McCarthy and his chief aide had antagonized the Senate establishment and had turned the Eisenhower administration openly and fatally against them.

When Mr. Cohn left government in the mid-1950s, McCarthy had been censured by the Senate for his conduct and was dying of apparent acute alcoholism. While others associated with McCarthy fell into obscurity, Mr. Cohn made a career as one of New York's most successful trial lawyers. He kept a high profile, maintaining several homes and a fleet of cars and dining frequently at New York City's most fashionable establishments.

Even in private life, he remained controversial.

In June 1986 he was disbarred by the Appellate Division of the state of New York Supeme Court in Manhattan for "dishonesty, fraud, deceit and misrepresentation." Among the instances cited by the court were his refusing to repay a $100,000 loan, violating an escrow order and lying in an application for admission to the D.C. Bar. The court also established that Mr. Cohn had entered the hospital room of dying multimillionaire Lewis Rosenstiel -- who was senile, drugged, and semicomatose -- and held his hand to sign a document naming Mr. Cohn as coexecutor of Rosenstiel's will after falsely telling him that the document dealt with his divorce.

"For an attorney practicing for nearly 40 years in this state, such misconduct is inexcusable, notwithstanding an impressive array of character witnesses who testified in mitigation," the court said.

Among those who came to his defense were columnists William F. Buckley Jr. and William Safire, television personality Barbara Walters, Rep. Mario Biaggi (D-N.Y.) and developer Donald Trump.

Mr. Cohn denied the charges and said he was disbarred because "the establishment bar hates my guts." He called his accusers "a bunch of yo-yos" out to smear him.

He also had been tried three times on criminal charges in New York -- in 1964 on stock-swindle charges and in 1969 and 1971 on charges of extortion, bribery and blackmail of a city official and of filing false reports to the U.S. Securities and Exchange Commission. He was acquitted of all charges.

In 1970 he was indicted for trying to gain control secretly of two Illinois banks, but the charges were dropped.

Since the 1970s, he was a frequent defendant -- and usually the loser -- in battles with federal, state and local governments over his income taxes. In April, the Internal Revenue Service claimed that Mr. Cohn owed nearly $7 million in back taxes and penalties. The case was pending at the time of his death.

By the IRS' count, the government had liens against Mr. Cohn totaling $3,187,381 and dating back more than 25 years.

Despite that, he managed to maintain homes on Capitol Hill and in Acapulco, Manhattan and New England. He drove a Bentley, a money-green Rolls-Royce and a Cadillac convertible, had a 12-seat private plane and had living expenses of about $500,000 a year. Mr. Cohn said that the homes and vehicles were owned by his firm or friends, and that he had no bank accounts, stocks or assets of any kind.

He maintained that many of his legal troubles stemmed from his work for McCarthy, especially his problems with the federal government. Robert F. Kennedy, the U.S. attorney general in the early 1960s, had been a counsel with Mr. Cohn on the McCarthy committee, and the two had nearly come to blows on occasion.

Mr. Cohn's theory on the origins of his problems was seconded by Irving Younger, a respected trial attorney and law professor. Younger said that as an assistant U.S. attorney under Robert M. Morgenthau in Manhattan in the 1960s, he was told by Morgenthau and Kennedy to "get" Mr. Cohn. Younger said he was unsuccessful in putting together a case. Morgenthau told The Washington Post that Younger's story was "absolute fiction."

During his New York heyday, Mr. Cohn's friends and clients were a remarkable and wide-ranging set. He counseled such people as the late FBI director J. Edgar Hoover and Cardinal Terence Cooke, fashion designer Halston and pop art guru Andy Warhol, and sports figure and businessman George Steinbrenner.

He was affiliated with the New York law firm of Saxe, Bacon & Bolan. Much of his practice focused on highly publicized divorce proceedings, estate battles and criminal law. Among his best-known clients in the latter category were the late Carmine Galante, a Mafia "boss of bosses," and Anthony (Fat Tony) Salerno, the alleged godfather of the Genovese mob.

Mr. Cohn had a reputation as one the country's most feared litigators. He was an audacious courtroom strategist and a more-than-competent back-room fighter as well. One client, a victorious and grateful Donald Trump, once said, "If you need someone to get vicious toward an opponent, you get Roy . . . . People will drop a suit just by getting a letter with Roy's name at the bottom."

Roy Marcus Cohn was born in the Bronx on Feb. 20, 1927. He was the only child of the former Dora Marcus and Albert Cohn, a respected New York State Supreme Court judge. Roy Cohn graduated from Columbia University in 1946 and earned his law degree there a year later. Too young to win admission to the bar, he became a clerk in the U.S. attorney's office.

After being admitted to the bar in 1948, he stayed on with the federal prosecutor's office, taking part in the historic prosecution of the Rosenbergs. Although the Rosenbergs were convicted and electrocuted, there are many who maintain that they were not guilty and many more who deplore the circumstances of the trial. But Mr. Cohn told The Post in an interview that it was his work on the trial that persuaded him that McCarthy was correct in believing that there was a high-level communist conspiracy in the United States.

In 1953, the Republicans controlled the Senate and McCarthy was chairman of the Government Operations Committee's permanent investigations subcommittee. It was this panel that Mr. Cohn joined, serving as its chief counsel for two years. He moved back to New York and private practice in 1954.

Over the years, he wrote four books: "McCarthy," "A Fool for a Client," "The Answer to Tail Gunner Joe" and "How to Stand Up for your Rights -- and Win."

The last book was dedicated to Joseph N. Welch, the lawyer who bested him in the hearings. Mr. Cohn always maintained that he was sincere in his admiration for Welch's legal talents. At the time of his death, Mr. Cohn was at work on his memoirs for Random House.

In December 1985, when he knew he was dying, he was asked how he wanted to be remembered. He said: "I have no choice. I don't think about it. Because I know how I am going to be remembered. I am going to be Joe McCarthy's chief counsel for the rest of my life, no matter what else good or bad I should ever do in anybody's eyes. And I'm perfectly happy with that denomination as long as those on the other side can see that there is another side."

Mr. Cohn never married and leaves no immediate survivors.