BP PLC's (BP) chief executive, John Browne, resigned Tuesday only hours after a judge cleared the way for a newspaper to publish details of his private life.

The company's board appointed Tony Hayward, who had been set to take over on Aug. 1, as the new chief executive effective immediately, BP said in a statement.

Browne had led Europe's second largest energy company for more than a decade. He had announced earlier this year that he would resign at the end of July.

He had been fighting since January to suppress details from an interview with a man with whom Browne had had a relationship from being published by the Mail on Sunday newspaper.

"For the past 41 years of my career at 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," Browne said in a statement.

"It is a matter of personal disappointment that a newspaper group has now decided that allegations about my personal life should be made public."

The company said Browne's decision to resign immediately meant he would lose a bonus of up to 1.3 times his annual salary, worth in total over 3.5 million pounds ($6.9 million). He would also forgo inclusion in the long-term performance share plan for 2007-2009 with a maximum potential value of some 12 million pounds ($23.9 million).

BP shares edged up 0.1 percent to 566 pence ($11.30) on the London Stock Exchange.

Browne — a close associate of Prime Minister Tony Blair — announced earlier this year that he would resign at the end of July following a series of high-profile mishaps including a deadly refinery blast in Texas and an oil spill in Alaska.

Last week, BP reported a 17 percent drop in first-quarter earnings on lower oil prices and declining production.

Browne's annual performance bonus for last year was cut almost in half as the oil spill and safety lapses in the United States overshadowed record profits for the oil company. But he leaves the company with a multimillion dollar payoff and pension.