Hong Kong CNN Business  — 

Just a few years ago, one in every five smartphones sold in China was made by Samsung. How times have changed.

The smartphone maker said this week it was shutting down its last phone factory in the country in the southern city of Huizhou. Its share of the vast Chinese market has collapsed and labor costs have risen. The world’s largest smartphone maker is now setting its sights on more promising markets.

“As part of ongoing efforts to enhance efficiency in our production facility, Samsung Electronics has arrived at the difficult decision to cease operations of Samsung Electronics Huizhou,” it said in a statement on Thursday. The South Korean firm declined to share more details, including when exactly it was shuttering its operations and how many employees worked at the plant.

At its peak, the plant was Samsung’s biggest in China, producing a fifth of all smartphones sold in the country, according to the South China Morning Post.

Speculation had been mounting that the facility would close. Last month, the factory posted recruitment notices for 13 other companies on its official WeChat account, suggesting followers should look at other job postings.

On Thursday, local news website Zhiwei Tech posted a video on Chinese social media platform Weibo that appeared to show workers signing up to get a free Samsung phone. The phone was intended as a parting gift for employees who had been with the factory for more than 10 years, the outlet reported. Samsung declined to comment on the matter.

A Samsung store in Seoul, South Korea.

The move came after years of lackluster sales in China that were hampered by several factors. As of the first quarter of this year, Samsung (SSNLF) accounted for just 1% of the Chinese smartphone market, according to Counterpoint Research.

The company’s share of the Chinese market had declined steadily since late 2016, when it suffered a sharp drop-off in demand because of the exploding Galaxy Note 7 crisis. Samsung’s delayed response to that situation led to a severe loss of consumer confidence, said Flora Tang, a research analyst at Counterpoint.

Prior to the crisis, Samsung was the one of the country’s top five smartphone vendors, and in 2013 accounted for around 20% of the Chinese market, she added.

The world’s biggest smartphone maker also lost out as local competition grew. Over the last few years, homegrown players such as Huawei, Oppo, Vivo and Xiaomi have become more popular, and they have “grabbed [market share] from Samsung with their strong product portfolio, affordable prices, more localized services ecosystem and extensive sales channels,” said Tang.

China’s smartphone market has also stalled in recent years, suffering its first ever annual decline in 2017 and its worst contraction in six years in the first quarter of 2019.

Now Samsung is expanding its manufacturing efforts in emerging markets, where it can benefit from lower costs such as cheaper labor. Around 60% of Samsung’s smartphones are now made in Vietnam, according to research firm Canalys.

Another big growth frontier for the Korean tech firm is India, the world’s second-biggest smartphone market. Samsung was the top seller there for years until it was leapfrogged by Xiaomi, sending both players into a tight race for the top spot.

Last year, Samsung opened what it called “the world’s largest mobile factory” in Noida, a city near New Delhi, which the company said would help it nearly double its annual capacity in the country.

Closing down the Chinese plant is a good option for the company to minimize its losses and shore up profitability, said Tang. “Its smartphone businesses in [Southeast Asia and] India appear more positive than that in China.”

CNN Business’ Laura He contributed to this report.