BP said the decision to replace Hayward, 53, with the company's first ever non-British chief executive was made by mutual agreement.
In a mark of faith in its outgoing leader, BP said it planned to recommend him for a non-executive board position at its Russian joint venture and will pay him 1.045 million pounds ($1.6 million), a year's salary, instead of the year's notice he was entitled to.
"The BP board is deeply saddened to lose a CEO whose success over some three years in driving the performance of the company was so widely and deservedly admired," BP Chairman Carl-Henric Svanberg said in a statement.
Svanberg said the April 20 explosion of the Macondo well on the Deepwater Horizon platform run by BP in the Gulf of Mexico has been a "watershed incident" for the company.
"BP remains a strong business with fine assets, excellent people and a vital role to play in meeting the world's energy needs," he said. "But it will be a different company going forward, requiring fresh leadership supported by robust governance and a very engaged board."
Besides permanently plugging the oil leak and cleaning up the spill and the company's image, Dudley will oversee the sale of $30 billion in assets over the next 18 months to bolster the company's finances.
Appearing briefly outside BP's London headquarters with Hayward and Svanberg, Dudley said that sealing the well was his priority and that he planned to focus on building relationships on the Gulf Coast and in Washington D.C.
"There's no question that we are going to learn a lot from this ... and I'm sure there will be changes," Dudley told reporters, as Hayward and Svanberg looked on without speaking.
Hayward, who has a Ph.D in geology, had been a well-regarded chief executive. But his promise when he took the job in 2007 to focus "like a laser" on safety came back to haunt him after the explosion on the Deepwater Horizon rig killed 11 workers and unleashed a deep-sea gusher of oil.
He became the lightning rod for anti-BP feeling in the United States and didn't help matters with a series of gaffes, raising hackles by saying "I want my life back," going sailing, and giving what was viewed as an evasive performance before U.S. members of Congress in June.
In a statement on Tuesday, Hayward said it was right that BP embark on its next phase under new leadership.
"The Gulf of Mexico explosion was a terrible tragedy for which - as the man in charge of BP when it happened - I will always feel a deep responsibility, regardless of where blame is ultimately found to lie," he said.
On top of the payout, Hayward retains his rights to shares under a long-term performance program which could eventually be worth several million pounds if BP's share price recovers. The stock has lost around 35 percent, or $60 billion, in market value to around $116 billion since the well explosion. The stock started out marginally higher on Tuesday, but was trading almost 1 percent lower at 413.35 pence in afternoon trade on the London Stock Exchange.
Hayward, who will remain on the board until Nov. 30, will also be entitled to draw an annual pension of 600,000 pounds from a pension pot valued at around 11 million pounds.
Svanberg described Dudley, 54, who was thrown out of Russia after a battle with shareholders in the company's TNK-BP joint venture, as a "robust operator in the toughest circumstances."
Currently BP's managing director, Dudley grew up partly in Hattiesburg, Mississippi, and has so far avoided any public missteps. He spent 20 years at Amoco Corp., which merged with BP in 1998, and lost out to Hayward on the CEO slot three years ago.
Dudley will be based in London when he takes up his appointment and will hand over his present duties in the United States to Lamar McKay, the chairman and president of BP America.
BP said the $32.2 billion charge for the cost of the spill led it to record a loss of $17 billion for the second quarter, compared with a profit of $4.39 billion a year earlier.
It is the loss in 18 years. The charge includes the $20 billion compensation fund the company set up following pressure from President Barack Obama as well as costs to date of $2.9 billion.
But the company also stressed its strong underlying financial position - revenue for the quarter was up 34 percent at $75.8 billion - and Hayward said it had reached a "significant milestone" with the capping of the leaking well.
Crews were restarting work to plug the leaky Gulf well after the remnants of Tropical Storm Bonnie blew through, forcing a short evacuation. The U.S. government's oil spill chief, Retired Coast Guard Adm. Thad Allen, said Monday that the so-called static kill - in which mud and cement are blasted in from the top of the well - should start Aug. 2.
If all goes well, the final stage - in which mud and cement are blasted in from deep underground - should begin Aug. 7.
BP said the bottom kill could take days or weeks, depending on how well the static kill works, meaning it will be mid-August before the well is plugged for good.
Hayward said the company expects to pay the "substantial majority" of the remaining direct spill response costs by the end of the year.
"Other costs are likely to be spread over a number of years, including any fines and penalties, longer-term remediation, compensation and litigation costs," Hayward said.
BP said the sale of $30 billion in assets will come primarily from its $250 billion Exploration and Production portfolio and assets will be selected "on the basis that they are worth more to other companies than to BP." The company has already made a start with the $7 billion sale of gas assets in the United States, Canada and Egypt to Apache Corp.
In London, Greenpeace protestors closed more than 50 service stations in a protest timed to coincide with the company's earnings update. The environmental action group is calling on Dudley to focus the company on greener and renewable sources of energy.
Richard Hunter, head of U.K. Equities at Hargreaves Lansdown Stockbrokers, said that significant challenges remain for the company but it is "moving aggressively to position itself for the tough times ahead."
"The triple pronged approach of increased provisions, asset sales and a new CEO should be a potent mix in forming a strong future foundation," Hunter said. "Behind the obvious headlines, the underlying trading performance was robust with a significant improvement having been made on a like for like basis."
The company reported that underlying replacement cost profit - the measure most closely watched by analysts - was $5 billion for the three months between April and June when adjusted for one-off items and accounting effects. That compared favorably with a $2.9 billion profit for the second quarter of 2009.
"Outside the Gulf it is very encouraging that BP's global business has delivered another strong underlying performance, which means that the company is in robust shape to meet its responsibilities in dealing with the human tragedy and oil spill in the Gulf of Mexico," Hayward said.
Higher prices for oil and gas made up for slightly lower output and a loss in gas marketing and trading in Exploration & Production, while Refining & Marketing reported increased profits as a result of strong performance in the fuels value chains and the lubricants and petrochemicals businesses.
The company said it planned to reduce net debt to a range between $10 billion and $15 billion within the next 18 months, compared to net debt of $23 billion at the end of June, to ensure that it had the flexibility to meet its future financial obligations.
Capital spending for 2010 and 2011 will be about $18 billion a year, in line with previous forecasts.