TAMPA, Fla. (AP) _ The huge Mexican glass company Vitro SA announced Sunday it had signed a definitive agreement to buy Anchor Class Container Corp. and Latchford Glass Co. of California for more than $900 million.

The Anchor deal, valued at about $800 million, would be the largest Mexican takeover of a U.S. company, Vitro said.

Vitro's protracted effort to take over Tampa-based Anchor, the nation's second-largest glass company, won approval by Anchor's directors after the glass giant raised its cash tender offer for Anchor stock from $20 to $21.25 a share. Anchor's board of directors in August rejected the $20-a-share bid.

''The acquisition of Anchor, which has nearly $1 billion in sales, is a unique strategic opportunity for Vitro SA to become a world player in the glass container industry,'' said Ernesto Martens, Vitro's chief executive officer.

The tender offer and withdrawal rights are scheduled to expire at midnight EST Oct. 27, Vitro said in a statement Sunday. Vitro already owns about 10.3 percent of Anchor's shares.

Vitro earlier announced a friendly merger agreement with Latchford, a small, privately owned glass maker based in Huntington Park, Calif. The Latchford deal was contingent upon the completion of the takeover of Anchor, Vitro said.

Vitro, based in Monterrey, is one of Mexico's largest publicly held companies, with more than 37,000 employees and a profit of $150 million in 1988 on revenues of almost $1.1 billion.

Vitro manufactures glass and plastic containers, flat glass, major appliances, tableware and glassmaking machinery, and operates joint ventures with such U.S. corporations as Ford Motor Co., Whirlpool Corp., Ingersoll-Rand Co., Owens-Corning Fiberglass Corp., and Samsonite Corp.

Anchor Glass made $978 million last year manufacturing glass containers for food, beverage, and cosmetics industries in 20 factories across the country. Latchford, which has two plants, has been making glass containers for food and beverage industries since 1917.

Vitro promised Sunday to keep Anchor's corporate headquarters in Tampa, and to run the company with U.S. managers as a fully independent U.S. subsidiary.

''We are confident that the combination of our companies will result in enhanced business and financial prospects for Anchor's employees, customers and communities,'' Martens said.

Anchor's chairman and chief executive officer, Vincent Naimoli, also predicted a ''sound and exciting future for the employees of Anchor Glass.''

Vitro has said it plans to modernize Anchor's plants so that its products are more competitive with the plastic and aluminum containers that have taken an increasing share of the U.S. market for food containers.

Lazard Freres & Co. and Donaldson, Lufkin and Jenrette Securities Corp. are managing the tender offer for a Vitro subsidiary, THR Corp., and Morgan Stanley & Co. Inc. is advising Anchor.

Security Pacific National Bank has committed to provide $139 million of financing for the Anchor tender offer. An affiliate of Donaldson, Lufkin and Jenrette has promised to provide a $155 million short-term loan for the separate buyout of Latchford, which was expected to close at the same time as the Anchor offer.