Allstate said the deal will help it tap consumers who prefer certain brands along with consumers who want choices among insurance carriers.
Esurance sells auto insurance directly to customers online and through call centers. Answer Financial is an independent personal insurance agency.
Allstate, based in Northbrook, Ill., has agreed to pay $700 million plus the tangible net value of the businesses being acquired. It estimates the total price would be about $1 billion.
It expects the deal to reduce earnings in the first year after the transaction closes, said company spokeswoman Maryellen Thielen. The company said in its statement that it expects the transaction won't lower earnings after the first year.
Last month, Allstate said its first-quarter profit more than quadrupled as it paid out less money for damage claims. The results handily beat Wall Street's expectations.
The company also said at the time that rate hikes on homeowners' insurance were approved in 12 states during the quarter. Allstate has said that it would work to improve returns in the homeowners unit, as a growing number of weather-related incidents such as hurricanes, wildfires and hailstorms in recent years has eroded the bottom line.
White Mountains shares rose $51.55, or 15 percent, to $395.18 Wednesday. Allstate shares edged up 3 cents to $32.45.