FORTUNE — To understand how Samsung — yes, Samsung — became America’s No. 1 mobile phonemaker and thorn in Apple’s side, it’s helpful to rewind to last fall. On a mid-September morning, Apple (AAPL) CEO Tim Cook stepped onto a stage in San Francisco to unveil the iPhone 5. Several hundred miles away, in a Wolfgang Puck restaurant in Los Angeles, a group of marketing executives from Samsung Electronics followed real-time reactions to Cook’s remarks. They huddled around tables mounted with laptops and TV screens, carefully tracking each new feature and monitoring the gush of online comments on the new device via blogs and social media sites. As the data flowed in, writers from the company’s advertising agency, who were also camped out in the restaurant turned war room, scrambled to craft a response.
Two hours later, when Cook stepped off the stage, the Samsung group was already drafting a series of print, digital, and TV ads. The following week — as the iPhone 5 went on sale — the company aired a TV ad mocking Apple “fanboys” queuing up for the new phone. (“The headphone jack is going to be on the bottom!”) The 90-second commercial went on to become the most popular tech ad of 2012, garnering more than 70 million views online. More important, in the weeks following the launch of Apple’s iPhone 5, Samsung sold a record-breaking number of its own signature smartphone, the Galaxy S III. “We knew this was going to be a big moment in time, when consumers are really paying attention,” says Todd Pendleton, chief marketing officer of Samsung’s U.S.-based mobile division. “We wanted to take that opportunity and all that energy and make it Samsung’s moment.”
No doubt about it, Samsung is having a moment. In recent years the South Korean company has taken the mobile world — the U.S. included — by storm. Last year it overtook longtime leader Nokia to become the No. 1 player in cellphones, with 29% market share worldwide. In smartphones, those high-end devices with advanced computing power, Samsung is also No. 1 globally and in a dead heat with Apple in the U.S.: Most analysts show Apple with a slight edge in smartphone sales, while one outfit, ABI Research, says Samsung’s share of smartphone shipments topped 33%, compared with Apple’s 30%. (To be sure, Apple sells one device, the iPhone, while Samsung offers 25 unique smartphones in the U.S.) “Samsung is on fire,” says John Legere, CEO of mobile operator T-Mobile USA.