Record gasoline prices are changing the equation of the refining business, generating unprecedented profits for the companies that transform crude oil into fuel.

For every barrel of oil they use to make gasoline, refiners are pocketing more than $30 in profit before taxes and other expenses. That is the most they have reaped per barrel since Hurricane Katrina in 2005. The major producers of gasoline in the U.S. earned about $10 billion from their refining operations domestically and abroad in the first quarter, up 50% from...