The original iPhone's development was an epic undertaking cloaked in layers of paranoid secrecy.

When Apple's smartphone went on sale on June 29, 2007, the world was dominated by flip phones and Blackberrys with tiny keyboards. People carried iPods for music, Palm Pilots for calendars, and compact cameras for photography. Putting all those things into a rectangle that fit in your pocked seemed crazy. Doing it without a keyboard was even crazier.

Ten years later, details have come out about what it really took for Apple (AAPL) to create a brand new gadget that changed the world. These are some of the stories of how the iPhone was born.

The iPhone exists because Steve Jobs couldn't stand someone at Microsoft

"It began because Steve hated this guy at Microsoft," said former Apple executive Scott Forstall during a recent talk at the Computer History Museum.

The Microsoft employee was married to a friend of Laurene Powell Jobs, Steve's wife, and they ran into each other at social events. One time, the man went on about how Microsoft was going to fix laptop computing with tablets and styluses.

"He just shoved it in Steve's face the way they were going to rule the world with their new tablets [and] with their pens," said Forstall. "And Steve came in on Monday, and there was a set of expletives, and then it was like, 'Let's show them how it's really done.'"

Jobs thought using a stylus was cumbersome and said people should use their fingers instead. So he had a group start working on a tablet with capacitive touchscreen technology.

Jobs wanted to make that technology phone sized, so Apple's design team whipped up a demo of an address book on a touchscreen.

"The second you saw this demo, you knew this was it. There was no question. This is the way that a phone had to behave. Steve saw it, and said, 'OK, put the tablet on hold, let's build a phone,'" said Forstall.

What it was really like to work for Steve %@*&ing Jobs

"He was the most intense person I've ever known," said Forstall at the Computer History Museum. "I've met a number of world leaders, and I can tell you from experience, having dinner with a world leader is relaxing compared to lunch on a Tuesday with Steve. He was super driven, very demanding. He forced people to do their best."

Jobs was known for yelling at employees and wielding colorful language. But his outbursts were preferable to his silence.

"Those were the times when Steve went from raging lunatic, screaming and yelling and berating everybody, to sitting in his chair," Andy Grignon, a former senior engineer at Apple, told CNN Tech. "We had these rocking chairs and him and Tim Cook, they sat on opposite chairs, and they would rock in sequence with each other. It was one of the weirdest things I had ever seen."

"Those were the times when you were most terrified ... It's when he shut the hell up and just had this pensive look and he was just contemplating, and you knew that we were all in trouble," said Grignon.

Related: Remembering Steve Jobs on the 5th anniversary of his death

Jobs and Grignon had a "tense" relationship -- at one point Jobs nicknamed him f**kchop -- but Grignon admits his style was effective.

"It was, in an odd way, very satisfying. I know that just sounds bizarre to hear after all of the verbal abuse, all of the random things, but to have him actually give you a compliment ... you were on cloud nine for the rest of the day," said Grignon.

There was another side to Jobs, according to Forstall: "He was really compassionate and dedicated to his friends and his relatives."

Jobs even saved his life once, said Forstall. He was in the hospital with a rare virus. He'd been sick for months and had lost 30 pounds, but the doctors weren't able to help him. Jobs snuck his acupuncturist into Stanford Hospital late one night. They worked until sunrise and Forstall started feeling better immediately.

"I was 100% dying, and Steve brought this person to me and saved my life. So I will always, always owe him that," said Forstall.

Psst, can you keep a secret?

Before the iPhone made its public debut at the Macworld convention in 2007, it was a top secret project at Apple's Cupertino headquarters. Apple officially started work on the iPhone at the end of 2004, and hundreds of employees were drafted to work on the project. It introduced a whole new level of secrecy to the company, as well as some creative office layouts.

Related: What to expect with the iPhone 8

Apple secured one floor with security cameras and badge readers for the iPhone team. It was dubbed the "Purple Dorm," and the "Fight Club" motto was posted on the door. ("The first rule of Purple Project is that you do not talk about it outside of those doors," said Forstall during a 2012 court case.)

Veteran Apple reporter Fred Vogelstein wrote a book on Apple and Google's race to dominate the smartphone market. He said Jobs believed it was important to keep iPhone information siloed within teams so it didn't leak.

"You would come to work on Monday and all of a sudden places that you used to access were off limits. During the weekend, workers had reconfigured the office space without telling you," Vogelstein told CNN Tech.

Employees couldn't talk about what they were working on with coworkers or their families. The high pressure environment and long hours took a toll on some employees. After a fight over who hadn't seen their kids more, one program manager slammed her office door shut and broke the lock. Unable to get the locksmith, Forstall, Grignon and others took turns whacking the door with a metal bat.

"It was probably the perfect summation of life in iPhone at that time. A bunch of people from all different parts of the organization just beating the s**t out of a lock that stemmed from an argument over who spent less time with their kids," said Grignon. "I mean how messed up is that?"

The ideas that didn't make it

The final iPhone wouldn't have been possible without a series of failed prototypes.

"Remember the click wheel iPod? Play, pause, next, previous, that kind of thing," said Grignon. "Imagine that same device, but zero through nine. A, B, C, D, E, F, all the way around in a circle and you dialed and texted like a rotary phone. It was as awful to use as it sounds, but that was our first attempt at making a phone."

There was a huge push to remove the SIM slot, according to Tony Fadell, a former senior vice president at Apple. Early versions had plastic instead of glass screens. There were long debates over whether to include a bezel -- the metal ring that surrounds the screen. One team wanted to base the operating system on Linux instead of Mac OS X.

Related: This was Apple's prototype for the iPhone

The iPhone's lack of a keyboard was one of Apple's most controversial, and ultimately successful, decisions. At one point, the team experimented with a "thin membrane keyboard that had no actual keys, it had little squares on it and you could just tap with your fingers," according to Grignon.

"The keyboard was absolutely the biggest decision that we had to make, whether it was going to have a hardware keyboard or whether it was going to be a software keyboard," Fadell told CNN Tech. "It would never be as good as a hardware keyboard, but without the hardware keyboard there were so many other benefits."

The near misses

The three year journey from idea to a shippable product almost went off the rails multiple times.

"It was a nightmare. It was a disaster a few times. We almost actually didn't ship a couple of times," said Grignon.

Apple's iPhone was a completely brand new product, from the chip to the operating system. It used an entirely new way to control a phone -- touch -- and it required new apps to be built from scratch.

"When you think about it, iPhone as a product never should have succeeded," said Grignon. "There were times when you got into the territory where, as deep as our bench was at Apple, we didn't know if we had the expertise to solve this particular problem."

Not all glitches were technical. Long before the famous iPhone 4 was found in a bar, Fadell left the original iPhone prototype on an airplane in Germany. He had to ask a team of people to search the plane without saying what, exactly, the device was.

"I'm like, 'It's a black thing. It looks like a piece of glass on one side, plastic on the other side. It's about a little bit larger than the size of a playing card deck. Please find this thing. I must have it. I have to have it.'"

It was found tucked into his seat cushions.

And then there was that final on-stage demo, when so much could have gone wrong. The team had multiple backups ready to go, but the demo went off without a hitch. And the rest is history.

"It was the worst professional experience I ever had," said Grignon. "But it was also the one with the best, probably greatest, result."