Samsung is recalling millions of new Galaxy Note 7 smartphones worldwide after reports that the devices can catch fire while charging.

The massive recall of one of Samsung's flagship devices is an embarrassing setback for the world's biggest selling smartphone maker. The Note 7 was unveiled just a month ago, and big rival Apple (AAPL) is expected to show off its new smartphone next week.

Samsung (SSNLF) said Friday it had found a problem with the battery in some of the phones and was halting sales in 10 countries, including South Korea and the U.S. It will offer customers a new product for free in the coming weeks to replace the 2.5 million Galaxy Note 7s that have been sold.

Samsung said devices in China don't appear to be affected because it used another battery supplier. But it was unclear if models sold in China would nonetheless be recalled.

The company originally said it would take about two weeks to prepare the recall, but later announced Note 7 users in the U.S. can exchange their device for a Galaxy S7 or Galaxy S7 Edge, starting next week. It will also refund the cost of Note 7-specific accessories.

Samsung is giving Note 7 users a $25 gift card or bill credit for the inconvenience.

More details about how the recall program will work will be announced shortly, the company said. In the meantime, people worried about their batteries should contact their nearest Samsung service center.

Target and Amazon said Friday that it has stopped selling the phone and is working with Samsung to replace the devices already sold in stores and online. Amazon and Best Buy have also said they are no longer selling the Note 7. Best Buy customers can return or exchange the phone if they already bought one.

U.S. mobile carriers AT&T, Verizon, T-Mobile and Sprint have suspended sales. Meanwhile, Sprint is offering up similar devices for customers to use during the recall process.

South Korean news agency Yonhap had previously reported that there have been five claims around the world of Note 7s catching fire while charging. Unverified photos posted on social media showed charred devices.

Related: Samsung Galaxy Note 7, a phone you can unlock with your eyes

A Galaxy Note 7 owner in South Korea, who asked that he not be identified, told CNNMoney he was awoken in the middle of the night when he "smelled something burning." His phone had melted and he used his older model Samsung, Galaxy Note 2, to take photos that he posted online.

"I saw small flames on the phone where it was melted," he told CNNMoney. "It disappeared soon after."

Samsung, a giant South Korean company, said it had been alerted to 35 claims of faulty phones worldwide. It said it had so far found 24 devices with problems for every million sold.

U.S. mobile networks sell the Galaxy Note 7 for at least $850. At a news conference, company executives declined to comment on exactly how much replacing all the devices would cost.

"It is a big amount that is heartbreaking," said Koh Dong-jin, president of Samsung's mobile communications business.

Samsung had the biggest share (22%) of the global smartphone market in the three-month period ending June 30, according to research firm IDC. By comparison, Apple held 12%.

Samsung benefited from the popularity of the Galaxy S7, IDC said, and the Galaxy Note 7 was expected to keep that momentum going into the second half of the year.

The phone was well received by reviewers, drawing attention for several unique features such as an iris scanner, which allows users to unlock the phone with their eyes.

-- Felicia Wong, Hope King and Julia Horowitz contributed to this report.