The Times Mirror Co. of Los Angeles, one of the largest communications empires in the country, has agreed in principle to buy the Denver Post, an afternoon newspaper with a colorful Wild West history, for about $95 million, the parties announced yesterday.

The Post, Denver's only afternoon daily, had been for sale since June. Several media companies had looked it over and decided not to buy. About three weeks ago, the Los Angeles Times, which is owned by the Times Mirror Co., published an article detailing the Denver paper's decline as a "hot property", noting it has been losing ground to its morning rival, the Rocky Mountain News, and saying that whoever, buys the Denver Post will have to spend a bundle to modernize its aging equipment.

"There's a gap in there somewhere," a jubilant Bill Hornby, the Denver Post's editor, said yesterday, referring to the contrast between the Times article and the Times Mirror Co.'s decision to buy his paper.

The company's willingness to pay $95 million for the Denver paper proves that things are not as bad as the Times article and some others have suggested, he said, adding, "We are absolutely delighted" that the paper has been bought by an organization like Times Mirror, which is "highly professional, puts out quality newspapers and, because it is a western-based company, understands Colorado and the West,"

Among the Times Mirror Co.'s other publishing holdings are the Dallas Times Herald, Newsday (on Long Island, N.Y.), the Hartford (Conn.) Courant and the magazine Sporting News. The company also owns two commercial television stations in Texas and several book publishing firms.

The Denver paper's editorial staff is especially happy that the new ownership is in the newspapering business, he said, mentioning recent speculation that the paper was going to be bought by Denver oilman Marvin Davis.

On Oct. 28, Hornby noted, the Post will celebrate its 85th birthday under the ownership of the Bonfils family. The paper's development since the boomtown days of 1895, when it was bought by a former bartender named Harry Tammen and a lottery and real estate swindler named Frederick G. Bonfils, has inspired two novels, the more recent of which, "Thunder in the Rockies," was written by the paper's editorial page editor, Bill Hosokawa.

One of the colorful tales of that era describes how Tammen and Bonfils were shot in the newspaper's office by an irate lawyer in an argument over how best to win a pardon for a convicted cannibal named Alfred Packer.

Today, 90 percent of the paper's stock is owned by foundations set up by the Bonfils family. The rest is owned by an employes' stock trust.

Frederick Bonfils' daughter, Helen, was an actress and theatrical producer. Through her interest in the theater she met the man who is now the paper's publisher and president, Donald R. Seawell, an attorney who once specialized in theatrical clients, according to Hosokawa.

During the 1960s, the paper engaged in a mammoth struggle to remain under independent local control, successfully repelling through the courts an attempt by the Newhouse newspaper chain to wrest control from Helen Bonfils, then the publisher.

It was as part of that struggle that the employe stock ownership plan was set up, Hornby said. But these days, he said, everyone at the paper realizes that "local ownership is an impossible dream."

The sale of the Post, whose daily circulation is about 260,000, expected to involve an initial $25 million cash payment from the Times Mirror Co., followed by a payment of $55 million after 10 years. Meanwhile, there would be semiannual payments of interest at the rate of 10 percent a year and payment of another $15 million over an additional 10-year period, according to the parties.

The deal is subject to approval by the boards of both companies and by shareholders at the Denver Post.

It was not immediately clear how the sale will affect Denver's performing arts center which, through the Bonfils foundations, has been supported almost entirely by dividends from the newspaper's earnings. But one informed Times Mirror source said pointedly, "It seems obvious, the paper will no longer be owned by those foundations."