Murphy Oil (NYSE: MUR) completed the divestiture of its North American refining operations this month when Valero Energy (NYSE: VLO) agreed to buy its last U.S. refinery, complete with inventory, for $625 million. The sale comes as a sigh of relief for Murphy, which had been trying to sell off its refining assets since last summer. As it turns out, the recent movement of oil and gas companies shedding their refining business is a win-win situation for everyone.

Refiners buy in
This purchase is the most recent in a line of strategic moves for Valero. The company sold two refineries in the Northeast because of slim margins caused by imported oil. The Murphy purchase increases Valero's presence on the Gulf Coast and, perhaps more importantly, enables it to increase capacity without the tremendous expense of an equipment upgrade.

Valero isn't the only refiner to walk away with a great find from the Murphy Oil tag sale; Calumet Specialty Products (Nasdaq: CLMT) is a winner as well. The refiner bought Murphy's operations in Superior, Wis., which immediately increased its capacity by 50% to 135,000 barrels a day. The company plans to issue $200 million in private placement debt to cover costs and a portion of the purchase price for the acquisition.

E&Ps sell out
Murphy joins Marathon Oil (NYSE: MRO) as two of the first major oil and gas companies to completely sell off their refining business in the U.S. ConocoPhillips (NYSE: COP) and Sunoco (NYSE: SUN) are also in the race to leave the refining game.

Sunoco acknowledged that its refining business was so bad that even if it cannot sell its refineries, they will go idle by next July. Similar to Murphy Oil, Sunoco's East Coast refineries suffered tremendously under competition from domestic oil, and what proved to be an insurmountable distance from current oil hotbed Oklahoma, where local refining competitors like HollyFrontier (NYSE: HFC) have been able to clean up. Figuratively, of course.

Foolish takeaway
All this wheeling and dealing presents a few options for investors. First, it is an opportunity to reconsider and pursue oil and gas plays that are becoming more efficient -- and hopefully more lucrative -- as they shed refining operations. Second, refineries with growing market share may warrant a second look as well, especially those that can convert cheap crudes in light of the current decline in U.S. demand for gasoline.

Looking for a few other great ideas in energy? Click here for the Motley Fool's Special Free Report "3 Stocks for $100 Oil."