Separately, the government said that it would cut financial support to militias who assist in providing security by the end of the year. The weak central government's authority is challenged by armed groups, but it also relies on them to keep order.
In its strongly worded statement on the oil terminals, the government said such dealings were a "blatant violation" of Libyan sovereignty and a "crime" punishable by law.
It said that it had a list of companies who it claimed were "trying" to buy oil and that they are under surveillance.
Air and naval forces were ordered to "confront any vessels (violating the order) with force, arrest and detention," the statement said.
Different militias took over the terminals this summer. Some have aspirations for self-rule in the eastern region while others accuse the government of corruption in oil deals.
Since the seizures Libya's oil production sharply declined from 1.4 million barrels a day to few hundred thousand barrels a day. The government has been negotiating with the militias and up until now has not used force against them.
Rebels-turned-militias have mushroomed in number and force since the toppling of longtime dictator Moammar Gadhafi in 2011.
The government said on Wednesday that it will stop paying militias by Dec. 31 this year. It said it was time to start "integrating the revolutionaries (into the army and police) and dismantling the armed groups."
"There will be no payments of any rewards or grants after this day except for an employee or a state worker" in the police and army, the statement said.