SAN FRANCISCO — Google is selling Motorola’s smartphone business to Lenovo for $2.9 billion, a price that makes Google’s biggest acquisition look like its most expensive mistake.The deal announced Wednesday will rid Google Inc. of a financial headache that has plagued the Internet company since it bought Motorola Mobility for $12.4 billion in 2012. Motorola has lost nearly $2 billion since Google took over, while trimming its workforce from 20,000 to 3,800. The business includes Motorola’s Moto X smartphone, which is being built at a 450,000-square-foot plant operated by Flextronics in the Alliance development in north Fort Worth. When the plant opened in August, with more than 2,000 employees, it was hailed for producing the first smartphone to be manufactured in the United States. Google Chairman Eric Schmidt and top executives from Flextronics and Motorola Mobility joined Gov. Rick Perry in Fort Worth to celebrate the plant’s opening in September.A Flextronics representative said the company would not comment on the impact of the pending sale on the Fort Worth facility.While Google is reversing courses, China’s Lenovo Group is gearing up for a major expansion. Already the world’s largest maker of personal computers, Lenovo now appears determined to become a bigger player in smartphones as more people rely on them instead of laptop and desktop computers to go online. It is also Lenovo’s second high-profile deal this month. The company announced plans last week to buy a major piece of IBM’s computer server business for $2.3 billion. Google is retaining most of Motorola’s mobile patents, providing the company with legal protection for its widely used Android software for smartphones and tablet computers. Gaining control of Motorola’s patents was the main reason Google CEO Larry Page decided to pay so much for Motorola Mobility when the smartphone maker was losing money and market share. Most analysts thought Page paid too much for Motorola and questioned why Google wanted to own a smartphone maker at the risk of alienating other mobile device makers that rely on Android. Selling Motorola’s smartphone operations will “enable Google to devote our energy to driving innovation across the Android ecosystem,” Page said in a statement. Lenovo is picking up about 2,000 Motorola patents in addition to the phone factories.