(Reuters) - Marathon Petroleum Corp (MPC.N) struck a deal to buy BP Plc's (BP.L) Texas City refinery and related infrastructure for up to $2.5 billion, a purchase that will make Marathon the fourth-largest U.S. refiner and give it a bigger potential slice of the market for refined product exports.

Marathon said on Monday it had agreed to buy the 451,000-barrels-per-day refinery, the fifth-largest in the country, as well as the plant's inventory, three intrastate natural gas liquids pipelines, four terminals and other assets.

The news sent shares in Marathon to a record high of $60.04 on the New York Stock Exchange. Since the stock began trading in June 2011, it has risen nearly 50 percent.

The base purchase price is $598 million, plus inventories estimated at $1.2 billion, Marathon said.

The agreement also contains a provision to pay up to $700 million more over six years, depending on the refinery's profitability.

"The multiple is cheap, that's why the shares of Marathon are up," said Pavel Molchanov, an analyst with Raymond James. "Texas City has a rather complicated history and that alone has made the valuation of this deal lower than it would have been otherwise."

The Texas City refinery was the site of a 2005 explosion, one of the worst industrial accidents in U.S. history. The blast killed 15 workers, injured 180 others and cost BP more than $3 billion to settle lawsuits and pay fines.