The chief executive of oil giant BP, Lord Browne of Madingley, has resigned from his post with immediate effect.
Lord Browne's resignation was a "tragedy" BP said.
Lord Browne said he had stepped down to save BP from embarrassment after a newspaper won a court battle to print details of his private life.
He also apologised that statements he had made in legal documents about a four-year relationship with Jeff Chevalier had been "untruthful".
Lord Browne had planned to step down from the company in July.
He will be replaced by his nominated successor Tony Hayward.
As a result of the decision, Lord Browne will lose at least £3.5m of his retirement package - and possibly a further £12m, BP said in a statement.
BP said it had accepted Lord Browne's resignation with "deepest regret".
"In my 41 years with BP I have kept my private life separate from my business life. I have always regarded my sexuality as a personal matter, to be kept private," Lord Browne said in a statement.
"It is a matter of deep disappointment that a newspaper group has now decided that allegations about my personal life should be made public."
He confirmed that he did have a relationship with Mr Chevalier who had now decided to tell his story to Associated Newspapers - owners of the Mail on Sunday.
However, he added: "These allegations are full of misleading and erroneous claims. In particular, I deny categorically any allegations of improper conduct relating to BP."
Lord Browne went to the House of Lords to try to win permission to appeal against earlier rulings which followed private hearings in the High Court and the Court of Appeal that would allow some details to be published.
The outgoing boss said that he had initially lied to the court about the circumstances in which he had met Mr Chevalier, because of "embarrassment and shock" at the revelations.
High Court judge, Lord Justice Eady said that he was not allowed to make allowances for the "white lie" told by Lord Browne.
BBC Business Editor Robert Peston called the resignation a "sad end to what was, until recently, a distinguished career".
He added that there probably were bigger blows to Lord Browne's reputation, such as an explosion at the Texas refinery that killed BP workers and led to stinging criticism of the firm.
Lord Browne had been at the helm of the company for more than a decade, however in recent months he had come under fire over the company's safety culture and his huge retirement package.
He had been due to leave BP with a £5.3m pay-off in July and a £21.7m pension, as well as millions of pounds in shares due under the incentive plan - a move many investors opposed.
Because of his decision to leave the firm early he will forfeit a significant chunk of those earnings.
BP chairman Peter Sutherland said that a review into allegations that company assets and resources had been abused were "unfounded or insubstantive".
"It is a tragedy that he should be compelled by his sense of honour to resign in these painful circumstances," he added.
The Mail on Sunday said that it was Lord Browne who had "made his private life a public issue" by lying in court.
"We would like to reiterate that the story we originally sought to publish was a business story involving issues of great importance to shareholders and employers of BP," the paper said.
Shares in BP barely moved on news of Lord Browne's resignation.
Analysts said that this was largely because the outgoing boss was already on his way out and that his successor was ready to step straight into the top job.