HOUSTON — BP, the British oil company, said on Thursday that it had agreed to pay $4.5 billion in fines and other penalties and to plead guilty to 14 criminal charges related to the rig explosion two years ago that killed 11 people and caused a giant oil spill in the Gulf of Mexico.

In a rare instance of seeking to hold individuals accountable for company misdeeds, the Justice Department also filed criminal charges against three BP employees in connection with the accident.

“This is unprecedented, both with regard to the amounts of money, the fact that a company has been criminally charged and that individuals have been charged as well,” Attorney General Eric H. Holder Jr. said at a news conference in New Orleans to announce the settlement.

The government said that BP’s negligence in sealing an exploratory well caused it to explode, sinking the Deepwater Horizon drill rig and unleashing a gusher of oil that lasted for months and coated beaches all along the Gulf Coast. The company initially tried to cover up the severity of the spill, misleading both Congress and investors about how quickly oil was leaking from the runaway well, according to the settlement and related charges.