Robert M. McKinney, former owner of The New Mexican in Santa Fe, regained control of the newspaper yesterday after a nine-year legal struggle with Gannett Co. Inc., which has owned it since 1976.

McKinney, 77, a resident of Middleburg, Va., was U.S. representative to the International Atomic Energy Agency in 1957-58 and ambassador to Switzerland under President John F. Kennedy. He bought the paper in 1949 and agreed to sell it in a stock exchange with Gannett in 1976.

Two years later, he filed suit against the newspaper chain, charging that the company had failed to abide by an agreement allowing him to maintain control as publisher for five years and editor in chief for 10 years.

The paper's board of directors suspended McKinney from the positions shortly after he filed suit.

During a long, bitter and complicated legal struggle, McKinney charged that Gannett had reneged on the agreement by firing the paper's general manager, refusing to soften an editorial critical of a New Mexico politician and refusing to fire the editorial page editor and another editor who disobeyed McKinney's orders about the editorial.

The legal battles became so intense that in one phase, when U.S. District Court Judge Santiago E. Campos had ordered the paper returned to McKinney, Gannett Chairman Allen H. Neuharth said the decision was based "on politics and provincialism rather than fact or law."

In the next round, Campos acknowledged Neuharth's constitutional right of free speech but said his statement was "a mendacity that is classic in its utter irresponsibility and naked maliciousness."

In a later phase, while Campos said he was "unscrambling the egg" to try undoing the original stock transfer, McKinney charged in court chambers that Gannett had engaged in a "scorched-earth policy" to decrease the paper's value before returning it to him.

Gannett's attorney argued at the time that it was "absurd" for the chain managers to try to kill a profitable paper.

After a conclusive ruling Aug. 7 by Campos in Santa Fe, McKinney was restored as publisher for almost three years and editor in chief for almost eight years.

McKinney immediately named a new general manager, replacing Diane L. Borden, who is exploring other job options with Gannett, according to a company spokesman.

"Now that The New Mexican is being returned to my management, my determination to ensure the best possible newspaper for northern New Mexico is redoubled," McKinney said in a statement. "For our readers, I hope to restore the newspaper to its former statewide preeminence in general excellence and community service."

McKinney, in what some observers saw as a reference to Gannett's policy of transferring people from paper to paper, also said he wants to build a staff "who consider themselves permanent residents of the community."

McKinney, who said in a telephone interview yesterday that he moved to Middleburg in 1975 after suffering heart trouble, said he has homes in Virginia, New York and New Mexico and hopes to spend "as much time as possible" in Santa Fe.