Williams Cos. said Monday it will buy natural gas producer Barrett Resources for $2.5 billion in cash and stock, topping a $2 billion hostile bid by the U.S. unit of Royal Dutch/Shell Group.

Denver-based Barrett put itself up for sale in a formal auction after Shell mounted its effort in March.

The boards of Williams and Barrett have approved the deal, Williams announced Monday. Shell had no immediate comment.