Updated

Yahoo has hired longtime Google executive Marissa Mayer as its next CEO in the Internet company's latest attempt to burnish its image and revive its financial growth after years of often-demoralizing upheaval.

The surprise move announced Monday makes Mayer the fifth Yahoo CEO in the past five years to attempt to turn around an Internet icon that has become as well-known for its follies as its online services.

Yahoo Inc., which is based in Sunnyvale, Calif., has lost its luster, while Google Inc. and Facebook surged ahead in the battle for the attention of Web surfers and marketing budgets of advertisers. The struggles have depressed Yahoo's stock, pressuring the company to find a leader with the charisma, vision and skills to turn the tide.

Mayer, 37, becomes the second woman to get a chance to salvage Yahoo. Silicon Valley veteran Carol Bartz spent more than two-and-half years as Yahoo's CEO before she was fired last September.

Yahoo picked Mayer over an internal candidate, Ross Levinsohn, who had been widely considered to be the front-runner for the job after stepping in to fill a void created two months ago when the company dumped Scott Thompson as CEO amid a flap over misinformation on his official biography.

Thompson's bio inaccurately said he had college degree in computer science — an accomplishment that Mayer can rightfully list on her resume. She earned a master's in computer science at Stanford University, the same school where the co-founders from both Google and Yahoo honed their engineering skills.

Plucking Mayer from Google represents a rare coup for Yahoo, said Gartner Inc. analyst Allen Weiner. "She brings great leadership and is very popular in Silicon Valley."

Yahoo shares added 33 cents, or more than 2 percent, to $15.98 in extended trading after Mayer's appointment was announced.

When Yahoo first contacted her June 18 about its CEO job, Mayer told The Associated Press on Monday, she wasn't interested in leaving Google. But she became increasingly intrigued with the challenge as her discussions with Yahoo's board progressed.

"I just saw a huge opportunity to have a global impact on users and really help the company in terms of managing its portfolio, attracting great talent and really inspiring and delighting people," Mayer said during an interview.

Although she had her responsibilities at Google narrowed two years ago, Mayer is still widely considered to among the Internet industry's brightest executives. A Wisconsin native, Mayer is a mathematics whiz with an impressive memory and a keen eye for design.

Mayer joined Google in 1999 as its 20th employee and went on to play an integral role in helping co-founders Larry Page and Sergey Brin exploit their online search technology to outmaneuver Yahoo and establish what still reigns as the Internet's most powerful company.

Along the way, Mayer helped oversee the development and design of Google's popular email and online mapping services. She also became a topic of Silicon Valley gossip during Google's early years as Page's girlfriend for three years. They have since gotten married to other people.

"We will miss her talents," Page, now Google's CEO, said in a statement.

In another statement, Google Executive Chairman Eric Schmidt hailed Mayer as "a great product person, very innovative and a real perfectionist who always wants the best for users. Yahoo has made a great choice."

Mayer becomes the second high-ranking female executive at Google to defect to one of the company's biggest rivals. Sheryl Sandberg, who helped expand Google's online advertising network, left in 2008 to become Facebook's chief operating officer.

"It's a bittersweet day for me," Mayer said. "Google is really my family. They have been life-defining for me."

As one of Google's earliest employees, Mayer already is extremely wealthy because of the stock options she received before the company went public in 2004. Yahoo didn't immediately define the terms of her contract as its new CEO.

Mayer's hiring threatens to alienate Levinsohn at a time he has been steering the company's efforts to feature more compelling content that persuades its website's 700 million monthly visitors to stick around for longer periods instead of spending so much time on the services of Facebook and Google.

This marks the second time that Yahoo has snubbed Levinsohn, 48, who previously had been best known for overseeing the Internet operation for Rupert Murdoch's News Corp.

Levinsohn had been vying for the CEO job after Bartz's firing, only to be passed over when Yahoo lured Thompson away from eBay Inc.

"Marissa's first order of business should be convincing Levinsohn to stay," Gartner's Weiner said. "If he leaves, there will be an exodus" among the Yahoo employees working on the content for the company's website.

Mayer declined to comment on any discussions she might have planned with Levinsohn.

Weiner views Mayer's decision to join Yahoo as a "no-lose" proposition for her.

"If she can pull this off and turn around Yahoo, it will make her legacy," he said. "If it doesn't work out, she can still walk away with great class and dignity."

Mayer starts at Yahoo Tuesday, when the challenges facing her should come into sharper focus with the scheduled release of the company's second-quarter earnings. The results are expected to show Yahoo's revenue growth remains sluggish, even as advertisers are spending more to promote their products and services on the Internet. Most of that money, though, has been flowing toward Google and Facebook.

Mayer said she intends to skip Yahoo's conference call to review the second-quarter numbers so she can spend more time meeting with the company's senior management team.