WASHINGTON—President Barack Obama, facing a bitter struggle within his own party on trade policy, warned that China would step into the economic vacuum the U.S. would create if it fails to complete and enact a free-trade deal with Asia.

“If we don’t write the rules, China will write the rules out in that region,” Mr. Obama said in an interview Monday with The Wall Street Journal. “We will be shut out—American businesses and American agriculture. That will mean a loss of U.S. jobs.”

Mr. Obama also warned of rising anti-globalization sentiment in Washington, reflected in Democratic opposition to the trade agreement, Republican efforts to kill the Export-Import Bank and congressional unwillingness to approve new rules for operation of the International Monetary Fund.

“What we can’t do, though, is withdraw,” Mr. Obama said, adding: “There has been a confluence of anti-global engagement from both elements of the right and elements of the left that I think [is] a big mistake.”

Mr. Obama and his negotiators are working to finish the Trans-Pacific Partnership, a trade deal among 12 Pacific nations that has come to be known as TPP, while also fighting to win “fast track” negotiating authority from Congress to expedite approval of the deal later this year. The trade agreement will be a topic of conversation between Mr. Obama and Japanese Prime Minister Shinzo Abe, who is scheduled to visit the White House this week.