The bill sponsored by Representative Joe Barton, a Texas Republican, passed the House 261 to 159, failing to reach the 290 votes necessary to overturn a presidential veto.
Only 26 Democrats voted for the bill despite Republicans' late effort to attract them by adding a measure to provide funds for the Maritime Security Program. The fleet of privately-owned ships brings supplies to U.S. troops and allies abroad.
The White House this week threatened to veto the House bill, saying Congress should work to move the country to cleaner sources of energy. The administration advocated measures including ending billions of dollars in tax breaks for oil companies and instead investing in wind and solar power and energy efficiency.
Congress passed the ban in 1975 after the Arab oil embargo caused snaking lines at gas stations and fears of global oil shortages.
Backers of repealing the trade restriction say it would keep the drilling boom alive and help U.S. allies find alternative sources of oil beyond Russia and the Middle East.
Opponents of lifting the ban, including the International Brotherhood of Electrical Workers union, say it will cost jobs in refineries and shipbuilding. Greens, meanwhile, say additional energy drilling will harm the environment.
Representative Frank Pallone, a Democrat from New Jersey, a state with several refineries, opposed the bill, saying it would be a "windfall to the oil industry."
Two similar bills in the Senate have passed through committees, but backers are struggling to find enough Democrats to pass legislation in the full chamber.