SAN FRANCISCO (Fortune) -- One of the most astonishing things about the new Apple iPhone, introduced yesterday by Steve Jobs at the annual Macworld trade show, is how Apple (Charts) managed to keep it a secret for nearly two-and-a-half years of development while working with partners like Cingular, Yahoo (Charts) and Google (Charts).

The iPhone, which won't be available in the United States until June, represents a close development partnership with America's largest wireless phone company (Cingular, now a part of AT&T (Charts), has 58 million subscribers), the world's largest e-mail service (Yahoo has a quarter-billion subscribers worldwide), and the world's dominant search company. Although speculation was rampant before the introduction that Apple would introduce a phone with iPod capabilities, actual details of the device were scarce. Even some senior Apple managers whispered during the keynote that they were seeing the iPhone for the first time, along with the 4,000 other Apple followers who crammed the Moscone meeting center here. Indeed, Apple's emphasis on secrecy may have influenced Apple's choice of Cingular to be the exclusive provider for iPhone service in the United States.

Apple, legendary for the ferocity with which it safeguards new product announcements, had extraordinary challenges in keeping the iPhone under wraps for 30 months. Besides involving Cingular, Google and Yahoo, not to mention the unnamed Asian manufacturer, the project touched nearly every department within Apple itself, Jobs said, more so than in any previous Apple creation.

No one thinks Apple went to the draconian lengths of some rivals, like Hewlett-Packard (Charts), which obtained phone records, read e-mail, riffled through trash and otherwise spied on board members, employees and journalists in order to track down leaks of confidential company information. (See correction.)

However, Apple does make it clear to employees and business partners that they will be dismissed and possibly prosecuted for leaking company secrets. Apple has also played the bully role, suing bloggers and other independent journalists for posting purported advance information about unannounced Apple products.

Secrets - along with patents - protect Apple against competitive threats from foreign companies that have become expert at instant cloning of Apple's products and designs. But secrets also create a major buzz factor. As the giant Consumer Electronics Show opened this week in Las Vegas, where hundreds of the world's biggest gadget and gizmo companies show off their newest and greatest gear, everyone was talking about the company that was not there - Apple - and speculating on what Steve Jobs had up the sleeves of his trademark black mock turtleneck shirt.

Many of the country's top technology analysts and journalists flocked to the Las Vegas airport Monday night, on the first day of CES, to be able to see Jobs reveal his secrets here Tuesday morning. Although their applications will be crucial parts of the iPhone experience, neither Yahoo nor Google saw the actual phone until shortly before the keynote, Jobs said. The software development was done without needing to provide a hardware prototype. In some cases, Apple deliberately disguised software builds, known as "stacks", to keep programmers from seeing the actual interface.

The Cingular partnership was especially complicated. Cingular had been a partner when Apple made its first foray into the phone business, providing iTunes software for the ill-fated Motorola (Charts) ROKR, unleashed in 2005. The norm in the telecom business is for carriers to dictate to phone manufacturers which features and technologies they want to offer to their subscribers, which is anathema to Apple culture. But in the case of the ROKR - which I reviewed as the STNKER - it was Motorola's meddling that drove Apple nuts. When the ROKR finally emerged, clumsy and underpowered, Jobs held it up on stage with all the enthusiasm of a man holding a dead rat by the tail. Jobs came out of the ROKR experience even more determined to maintain total control over what he called the reinvention of the telephone.

However, he said, he enjoyed working with Cingular. And apparently the sentiment was mutual. Two years ago, Jobs and Cingular's chief executive, Stan Sigman, got together to forge a multiyear pact to work together on the iPhone. The Apple phone didn't even exist as a sketch at that point, but apparently Sigman trusted that Jobs and Apple would deliver on their promise to revolutionize the mobile handset. And Apple trusted Cingular not to meddle in the hardware or feature design. "They let Apple be Apple," one Apple executive said.

Cingular worked with Apple software developer on breakthrough features like visual voicemail - the ability to see a list of voicemail messages in a list and choose to listen to them in any order, instead of sequentially, as most carriers require today - while Apple focused on what it does best, the close integration of elegant hardware design with powerful but simple-to-use software. Even so, Apple didn't show Cingular the final iPhone prototype until just weeks before this week's debut. In some cases, Apple crafted bogus handset prototypes to show not just to Cingular executives, but also to Apple's own workers.

Meanwhile, Jony Ive, Apple's design guru, was refining the sleek, final design. At the Macworld keynote, with Cingular's Sigman on stage with him, Jobs hinted again that the exclusive, multiyear partnership with Cingular would yield more phones that just the two iPhone models unveiled today. (The two are basically identical: A $499 device with four gigabytes of internal memory, and a $599 version with eight gigabytes.)

In the end, Apple decided to reveal the iPhone several months ahead of its official June launch because it could not keep the secret any more. Apple has to file with the Federal Communications Commission (FCC) for the permits needed to operate the iPhone, and once those public filings are made, Apple has no control over the release of that information. So, Jobs said, he made the decision to have Apple tell the world about its new phone, rather than the FCC.

Pillow talk was a challenge at the other end of the spectrum. Keeping secrets from loved ones is especially hard. Those stresses were amplified by the frantic race over the past half year to get the iPhone ready for launch. As Macworld approached, dinners were missed, kids were not tucked in properly, and family plans were disrupted, especially over the holidays. And for what? "Sorry, that's classified" is not considered a satisfactory answer in many households when Mom or Dad misses the school play or the big wedding anniversary dinner.

Phil Schiller, Apple's head of marketing and one of the few Apple executives involved with the project from the start, said he had to keep the iPhone development secret even from his wife and children. When he left home for the official unveiling yesterday, Schiller said, his son asked, "Dad, can you finally tell us now what you've been working on?" Jobs paused during the keynote to acknowledge the strain and sacrifices that the past months have brought not just for the employees who kept the secrets so well, but also for their families. "We couldn't have done it without you," he said, with obvious sincerity.

Correction: An earlier version of this story incorrectly described HP's monitoring of employee, director and journalist communications. CNNMoney.com regrets the error. (Return to story)