Mayer starts in the role today, bringing to an end Yahoo's period without a leader following the resignation of Scott Thompson in May amid health issues and in the wake of a storm over inaccurate information on his CV.
Interim chief executive Ross Levinsohn, who is head of global media, had been one of the favourites to succeed Thompson.
Hiring someone with Mayer's background in software engineering "signals a renewed focus on product innovation to drive user experience and advertising revenue", according to Yahoo.
Mayer was Google’s 20th employee and first female engineer and managed the launch of more than 100 products and features including image, book and product search, toolbar, iGoogle, Google News and Gmail.
She revealed yesterday on Twitter she was expecting her first child in October. According to Fortune magazine she disclosed this to the Yahoo CEO search committee in late June.
None of the Yahoo directors, she told Fortune, revealed any concern about hiring a pregnant chief executive. "They showed their evolved thinking," she said.
Mayer is also on the board of directors of Wal-Mart Stores and several non-profit organisations including the New York City Ballet.