Facebook chief operating officer Sheryl Sandberg has become an ally for Marissa Mayer after the Yahoo! chief came under fire for ordering stay-at-home employees back to the office.

In an article published on Thursday to herald the release of her first book Lean In, described by Sandberg as a ‘sort of feminist manifesto’, the multimillionaire businesswoman suggested that critics jumped on her friend Marissa’s decision because she is a woman.

Mayer released a memo last month requesting that all remote employees report to office facilities by June 1, saying: ‘Speed and quality are often sacrificed when we work from homeWe need to be one Yahoo!, and that starts with physically being together.’

Employees’ unhappiness appeared to be compounded by the fact that Mayer, 37, recently built a nursery adjoining her Silicon Valley office, so that she could spend more time with her son who was born in September.

Sandberg, a 43-year-old mother-of-two who has a personal fortune of $500million, appeared to back Mayer’s decision when asked about how successful women are viewed.

The Facebook COO told Time: ‘No one knows what happened there. I think flexibility is important for women and for men. But there are some jobs that are superflexible and some that aren’t.’

Sandberg’s interview was ahead of the release of Lean In: Women, Work and the Will To Lead, which will be published next week.

In the book, which falls between a memoir and career guidance for women, Sandberg says that women can succeed in the corporate sphere with a combination of good fortune, hard work and help from other people – but that they need to be more ambitious.

Lean In draws from Sandberg’s own anecdotes as she climbed the corporate ladder, first at Google and now Facebook, to become one of the most powerful women in the tech industry.

She writes about a moment when a group of all-male financiers were unable to tell her where the female toilet was because nobody had ever asked for it.

She was giving a presentation in a private equity company boardroom and asked to use the restroom when she got a shock. Sandberg asked: ‘Am I the only woman to have pitched a deal here in an entire year?’

The client replied: ‘I think so, or maybe you’re the only one who had to use the bathroom.’

To tie in with the book’s launch, Sandberg posed for a profile in the new issue of Vanity Fair and has been photographed with one of her two children in black and white by Annie Leibowitz.

She is also on the cover of this week’s Time magazine

In the book she urges women not to ‘lean back’ when it comes to their lives, but to ‘lean in’ – give it 100% in all areas of their life – so they can ‘have it all.’

But with a lavish lifestyle including private jets, a working day that often finishes at 5.30pm and an $8m, 9,000 sq ft mansion in Atherton, California, many have questioned how she can relate to the average working mother.

Speaking to CBS, Sandberg said: ‘When it comes to ambition to lead… men, boys, outnumber girls and women.

‘Women attribute their success to working hard, luck, and help from other people.

‘Men will attribute whatever success they have to their own core skills…

‘…I’m not blaming women. My message is not one of blaming women. There’s an awful lot we don’t control.

‘I am saying there’s an awful lot we can control to sit at more tables and raise more hands.’

Asked about her success, Sandberg showed surprising reluctance to grandstand or put it down to her own efforts.

Asked by interviewer Norah O’Donnell what her secret was, Sandberg replied: ‘I think my success, if I honestly want to attribute it, it’s attributed to a lot of things, some of which are luck, working hard and help from others. And my core skills.’

O’Donnell said: ‘But Sheryl, you are one of the most powerful women in the world and you still can’t attribute your success to your core skills?’

Sandberg replied: ‘I can more.’

Sandberg writes that the the feminist revolution has ‘stalled’ and that women earn 20 per cent less than men over their lifetime if they decide to have children. She also uses vivid analogies to describe what it is like to be a woman at work.

She writes: ‘Imagine that a career is like a marathon … a marathon where both men and women arrive at the starting line equally fit and trained. 

‘The gun goes off. The men and women run side-by-side. The male marathoners are routinely cheered on: ”Looking strong! On your way!”

‘For women however, the shouts are: ”You know you don’t have to do this!”’

Sandberg’s book has been called the first shot in a new book ‘mommy war’ by author Joanne Bamberger.

Sandberg, who has two degrees from Harvard, has not helped herself with controversial speeches in which she has said: ‘The moment a woman starts thinking about having a child, she doesn’t raise her hand anymore.’

She worked at Google and consultants McKinsey before joining Facebook in 2008 where she has been credited with driving the growth of the business.

According to the company’s SEC filing, she earned $31million in 2011, including stock options, making her one of the highest paid female executives in the U.S.