The US Internet giant said in a statement it "believes the plaintiffs' claims are without merit and will vigorously pursue all appeals."
The California company's statement offered few details on the case.
It said the 49th Civil Court of the Federal District of Mexico City has "entered a non-final judgment of US $2.7 billion against Yahoo! Inc. and Yahoo de Mexico" in the case.
The lawsuit was brought by Worldwide Directories SA de CV and Ideas Interactivas, and "alleged claims of breach of contract, breach of promise, and lost profits arising from contracts related to a yellow pages listings service," Yahoo! said.
Yahoo! shares were down 1.4 percent in after-hours trade on the news.
Yahoo! in October reported that its quarterly profit rocketed above $3 billion, fueled by the sale of part of its stake in Chinese e-commerce giant Alibaba.
The California company's revenue from display advertising was little changed from the same quarter last year but Yahoo! reported its income from ads served up with online search results was up 11 percent.
It has been trying to reinvent itself as the search pioneer has been overtaken by Google.
For the latest tech news and reviews, follow Gadgets 360 on X, Facebook, WhatsApp, Threads and Google News. For the latest videos on gadgets and tech, subscribe to our YouTube channel. If you want to know everything about top influencers, follow our in-house Who'sThat360 on Instagram and YouTube.