Lufthansa had held talks with both IAG and Virgin Atlantic about a possible sale of the airline, which reported a £130m loss for the first nine months of the year and employs more than 3,500 staff.
IAG has not ruled out job cuts following its purchase of BMI, but said that restructuring costs would be spread over three years.
As part of the deal, it has the option of selling of BMI Baby, its low-cost brand, and its BMI Regional business.
Willie Walsh, IAG chief executive, said: "Buying BMI's mainline business gives IAG a unique opportunity to grow at Heathrow, one of our key hub airports. Using the slot portfolio more efficiently provides the option to launch new long-haul routes to key trading nations while supporting our broad domestic and short-haul network."
The deal, which includes BMI's highly prized runway slots at London's Heathrow airport, will be subject to clearance from competition bodies.
Sir Richard Branson, chairman of Virgin Group, said: "BA is already dominant at Heathrow and their removal of BMI just tightens their stranglehold at the world's busiest international airport.
"We will fight this monopoly every step of the way, as we think it is bad for the consumer, bad for the industry and bad for Britain."
Follow John Reynolds on Twitter @johnreynolds10