But Michael Grimes of Morgan Stanley, a gadget enthusiast with a computer science background, has managed to become Silicon Valley’s banker of choice for initial public offerings.

After the dot-com bust of 2000, many Wall Street bankers retrenched when business dried up. But Mr. Grimes stuck around. With few deals to be done, he quietly networked, visiting venture capitalists, entrepreneurs and engineers.

His patience and connections are paying off, for him and for Morgan Stanley . In recent months, he has shepherded nearly every big initial public offering, including LinkedIn, Zynga, Grouponand Yandex.

Now, Mr. Grimes, 46, is in the final days of preparation for his biggest act: the I.P.O. of Facebook. The social networking giant’s I.P.O., which could raise $10 billion for the company, is on track to be largest Internet offering since Google’sin 2004.

Morgan Stanley could collect more than $35 million for its work on Facebook, depending on the size of the offering. That would add to the $173.3 million in fees the firm has earned in the last year — the most on Wall Street — for leading 28 technology I.P.O.’s, according to data from Thomson Reuters. It is a bright spot for Morgan Stanley at a time when the bank and others find their overall profits under pressure.

“Momentum is everything in Silicon Valley,” said Lise Buyer, the founder of Class V Group, an advisory firm for initial public offerings and a former Google executive. “The Valley tends to go with what worked last time.”

Mr. Grimes, with a short crop of rusty-brown hair and blazers that often seem a size too big, spent years cultivating connections in the start-up community, building a reputation as a banker who offered personalized service, industry understanding and a distinct strategy.

When Mr. Grimes courted the offering of LinkedIn last year, he advised the executives to avoid the vortex of Facebook. The professional social network, Mr. Grimes counseled, needed to go public on its own terms, rather than being swept up in the frenzy of Facebook’s pending I.P.O., according to people with knowledge of the discussions. In May 2011, LinkedIn went public, kicking off a new wave of Internet offerings.

“He was known as the whip-smart Cal Berkeley engineer who really understood technology,” said Mary Meeker, who worked with Mr. Grimes at Morgan Stanley and is a partner at Kleiner Perkins Caufield & Byers, the venture capital firm. “He’s very creative and goes to meetings with the mind-set that the team needs to earn and re-earn the client’s confidence at every turn.”

Michael Grimes declined to comment for this article.

Not all of the newly public stocks have proved to be as good for investors as they have for Internet entrepreneurs and their bankers. Yandex , Pandoraand Groupon are all trading below their offering prices. Groupon has also faced accounting issues, before and after its I.P.O.

Even so, Mr. Grimes most likely takes home a multimillion-dollar paycheck. Though Morgan Stanley does not disclose his compensation, a Wall Street executive at his level can make $7 million to $12 million a year.

His connections have counted. In 2001, he befriended Sheryl Sandberg, who became a young Google executive and is now the chief operating officer at Facebook. Mr. Grimes regularly visited Ms. Sandberg, offering free advice to the search company on financial issues like stock sales and acquisitions.

When Google prepared to go public in 2004, most of Wall Street balked at Google’s plan to run a so-called Dutch auction to sell its shares to the public. Goldman Sachs , for example, told the company it was the wrong approach. But Mr. Grimes was willing to try, and Morgan Stanley was named the primary banker on the deal.

“Other bankers said we were amateurs,” said Ms. Buyer, who worked on Google’s offering. “While Michael may have thought that, he was willing to change his mind.”

Although the offering faced some challenges, Google went public in 2004, raising $1.67 billion. According to Ms. Buyer, Mr. Grimes impressed Google’s top executives, including one founder, who asked why someone with enough intellectual prowess to be an engineer ended up as a banker.

From an early age, Mr. Grimes seemed headed for a career in technology. Growing up in East Los Angeles in a modest two-bedroom house with his sister and parents, Mr. Grimes attended the Polytechnic School, a prestigious prep school in Pasadena, Calif. His father, David Grimes, the owner of a mapping and land-surveying business, worked Saturdays to afford his son’s $5,000-a-year tuition.

At the age of 12, Mr. Grimes asked his father for the latest Applecomputer, a $2,500 machine that many of his wealthier friends owned. His father made a deal with him. He would buy the machine if his son converted some computer programs his father had developed into Apple’s programming language.

“He did it in one summer,” said David Grimes. “I guess I pushed him in that direction.”

While studying electrical engineering and computer science at the University of California, Berkeley, the younger Mr. Grimes briefly worked for Hughes Aircraft as a software engineer. But he soon gravitated toward a career on Wall Street, eager to find financial security.

“He looked around the world, and he asked, ‘Who makes a lot of money?’ And he thought, ‘Well, bankers do,’ “ David Grimes said, recalling a conversation with his son in high school.

After college, Mr. Grimes became an associate with Salomon Brothers in 1987, before joining Bear Stearns for a few years. Then one of the industry’s biggest rainmakers, Frank Quattrone tapped him to join Morgan Stanley in 1995.

Photo by Jodi Gralnick for CNBC.com

Facebook IPO hat

A showman with theatrical flair, Mr. Quattrone had spent more than a decade turning Morgan Stanley into a powerhouse. Then, in 1996, Mr. Quattrone abruptly left the firm for Deutsche Morgan Grenfell, taking most of the office with him. Facing a gutted practice, Mr. Grimes, a junior vice president at the time, chose to stay.

As he moved aggressively to rebuild the practice with his co-head of technology Paul Chamberlain, Mr. Grimes developed a reputation as a tough banker who fought for his share and sometimes squeezed out rivals. Two financiers, who spoke on the condition of anonymity, said the firm has also been known to overlook the opinions of rival bankers.

Ms. Buyer said, “He tries to make the client happy. But that doesn’t mean he played as nicely with” others.

In Silicon Valley’s hyperconnected world, Mr. Grimes’ initial band of friends has generated an ever-expanding network of contacts and deals.

In 2009, Sequoia Capital, an early backer of Google, asked Mr. Grimes to advise one of its portfolio companies, AdMob, which was in deal talks with Apple. The mobile advertising network’s chief Omar Hamoui was reluctant to hire any bankers. But Mr. Grimes made a persuasive pitch.

“He said, whatever our fee is, we believe we’ll get a lot more value out of this transaction for you, around the edges,” said Mr. Hamoui.

At first, the bank’s impact was limited, in part because Mr. Grimes didn’t have deep ties to Apple’s executives, according to Mr. Hamoui. Mr. Grimes eventually orchestrated a $750 million deal with Google, which agreed to a stunning $700 million breakup fee.

When Mr. Grimes pitched Ancestry.com, a genealogy Web site, in 2009, he showed the company an elaborate family tree he and his mother created. As an homage to the company’s logo, Mr. Grimes wore a green Hermès tie dotted with leaves to the meeting. After board member Victor Parker asked him where he purchased it, Mr. Grimes casually took off his tie and gave it to him.

“The other bankers were all about numbers,” recalled David Goldberg, an Ancestry.com board member and the husband of Ms. Sandberg. “It was clear he spent hundreds of hours on his family tree. He was just more personal.”

Mr. Grimes spent years laying the groundwork for the Facebook I.P.O., a debut that could value the company at nearly $100 billion.

After Ms. Sandberg joined Facebook in 2008, Mr. Grimes remained close. He was influential in convincing Ms. Sandberg’s husband to join Benchmark Capital several years ago as an entrepreneur in residence. (Ms. Sandberg recused herself from the process to pick underwriters for Facebook.)

He also built relationships with others in the Facebook network. After the Russian billionaire Yuri Milner made his first investment in the social network in 2009, Mr. Grimes sent Facebook’s finance team engraved blue Lucite folders to commemorate the occasion.

On Monday, the culmination of his efforts was on display as Facebook began its I.P.O. roadshow. Standing in front of a packed Sheraton ballroom in Manhattan, Mr. Grimes introduced Ms. Sandberg and Facebook’s chief financial officer, David Ebersman, to hundreds of prospective investors. Against a backdrop in Facebook’s signature blue, Mr. Grimes made perfunctory remarks, before giving the stage to his clients.