Mario Vazquez Rana, Mexico's largest newspaper publisher, yesterday won control of United Press International, ending a year-long bankruptcy battle in which he fought off more than a dozen other bidders and waded through a complicated legal thicket for ownership of the news agency.

UPI officials said they hope the closing of the sale, which is expected today, will end the turbulence and financial uncertainty that has threatened the wire service's survival for the past several years.

Vazquez already has pumped $2.5 million into the company and will inject another $12.5 million in what officials said will be the first major infusion of capital in more than a decade. Vazquez also has pledged another $25 million to pay UPI's creditors, back taxes and administrative expenses of the company's bankruptcy proceedings.

His plan to bring UPI out of bankruptcy was approved at a hearing yesterday by George F. Bason, the U.S. bankruptcy judge in the District of Columbia.

Since filing for bankruptcy in April 1985, UPI has continued to operate while it negotiated a plan of reorganization with its creditors and the union representing its workers.

Vazquez's bid for the company was endorsed last fall by UPI's management, the Wire Service Guild and a committee of its unsecured creditors. But the sale was challenged by lawyers for UPI's owners, who had become embroiled in a bitter fight with management, and lawyers for the Financial News Network, which tried unsuccesfully to buy the wire service. These challenges were dropped, however, after an out-of-court settlement last month.

Yesterday's approval came after UPI lawyers told the judge that unsecured creditors who are owed about $20 million overwhelmingly approved the plan, which will give them about $9.5 million, or roughly 45 cents on the dollar. These creditors include American Express Co., owed about $1.5 million, and AT&T Communications Inc., owed about $6.7 million.

Vazquez told the judge he would "do everything possible to make UPI the best news agency in the world."

The hearing ended with UPI Chairman Luis Nogales presenting the judge with a blue UPI necktie and thanking him for his 14-month handling of the bankruptcy proceedings. Bason, who appeared moved to tears, said he was confident that UPI's "future is now assured for the forseeable future."

UPI achieved a $1.3 million profit in 1985 after suffering massive losses in previous years. While the company has slipped back into the red this year, company officials say they hope the Vazquez investment will help turn it around and stem the erosion of UPI's subscriber base. Many publishers and broadcasters have dropped UPI in recent years, depending on the rival Associated Press and supplemental news services for their material.

The Mexican millionaire has been vague about his plans for the wire service. He has said he wants to beef up UPI's coverage of sports, international and business news, as well as to repair the company's aging computer and telecommunications equipment.

Vazquez also has said he wants UPI's current employes and executives, including Nogales, to stay, but his precise plans are unclear, employes and officials said yesterday.

Nogales, who several officials credited as the architect of UPI's turnaround, said yesterday he has had no discussions about his future with Vazquez and that he wants to stay only if he can have a "significant policy role."

UPI officials said that Vazquez and a handful of his representatives have spent the past several months studying UPI's finances and operations, and, in a message to employes yesterday, the new owner indicated this process of review would continue.

"Change and impovement wil not come overnight," Vazquez said in a statement distributed to UPI employes, who in 1984 accepted a 25 percent wage cut to help the wires service through its financial crisis. "We will undertake an extensive review of the company, followed by months of careful planning," he said.

In a letter scheduled to go out to UPI subscribers today, Vazquez also took head-on one of the major concerns expressed by U.S. news media executives in recent months -- foreign ownership of the agency.

"On this subject, let me be unequivocal," Vazquez was quoted by a UPI spokesman as writing, "I have no interest or intention of using the news agency to further any personal ambition, to favor any person, any cause, any region, or any country."