NATO said forces loyal to Muamar Gaddafi had laid mines on the approach to the harbour, under siege for weeks, and forced a temporary halt in humanitarian shipments, but had not taken control of the port. Libya's government claimed earlier it was in control of the port and that vessels would only be allowed in with government permission.
Further west, the war spilled into Tunisia when Gaddafi's forces overran a rebel enclave at the frontier. The Libyan army shelled the Tunisian border town of Dehiba, damaging buildings and wounding at least one person, witnesses said. They said Libyan soldiers drove into the town in a truck chasing rebels.
NATO said sea mines had been laid about three kilometres (1.5 miles) from Misrata harbour, used to ferry in humanitarian aid and evacuate wounded to the eastern rebel capital of Benghazi. Three had been found and were being disarmed.
"NATO forces are now actively engaged in countering the mine threat to ensure the flow of aid continues," NATO said.
Libyan government spokesman Mussa Ibrahim made no specific mention of mines, but said: "We will not allow weapons and supplies to come through the sea port to the rebels.
"We have proven the rebels in Misrata have been gaining weapons from Benghazi, from Qatar and other locations...in the last few weeks. We will not allow this," he said.
Libyan state television said government forces had rendered the port non-functional and "any attempt to enter the port will be attacked, regardless of the justifications."
A local resident said by telephone that the port itself remained in rebel hands and NATO said rebels were continuing to expand their perimeter around Misrata.
"If Gaddafi's forces take control of the port, it will be a disaster," said Ghassan, who lives close to the port.
Poorly armed and trained rebel groups have been fighting since mid-February to end Gaddafi's 42-year rule. A United Nations resolution allows British and French-led NATO air forces to attack government positions to protect civilians; but the support has not brought the swift fall of Gaddafi some expected.
After weeks of stalemate on the Mediterranean coastal road, Gaddafi has turned his firepower on rebel western enclaves such as Misrata and the mountainous area near the Tunisian frontier.
Tunisian Deputy Foreign Minister Radhouane Nouicer, speaking on Al Jazeera television, said casualties, including a young girl, were inflicted when the conflict spilled over on Friday.
"We summoned the Libyan envoy and gave him a strong protest because we won't tolerate any repetition of such violations. Tunisian soil is a red line," he said.
The Libyan government said rebels had briefly pushed its forces into Tunisia and that it was coordinating with Tunisia to avoid a disaster in the border area.
"We are respecting the sovereignty of the Tunisian country and state," spokesman Mussa Ibrahim said.
A Reuters cameraman who crossed into Libya from Dehiba saw the bodies of three Gaddafi soldiers on the ground. It was not clear if they had been shot by rebels or by Tunisian forces.
Tunisian border guards had shut down the border, he said. They were laying barbed wire and fortifying their positions.
Libyan refugees fleeing the fighting in the Western Mountains were reaching the crossing but unable to get through.
Reuters photographers in Dehiba, a short distance from the border, saw several abandoned pick-up trucks which Gaddafi loyalists had driven. One had a multiple rocket launcher on the back. Another, which had overturned and lay upside down in the sand, was fitted with a heavy calibre machine gun.
Tunisia's defence ministry said the Libyan soldiers who crossed the border had all been gathered up and taken home.
Tunisia toppled its own veteran leader, Zine al-Abidine Ben Ali, in a revolution earlier this year that triggered turmoil through the Middle East and many Tunisians are sympathetic to the rebels fighting Gaddafi's forces.
Rebels seized the Dehiba post a week ago. It controls the only road link which their comrades in the Western Mountains have with the outside world, making them rely otherwise on rough tracks for supplies of food, fuel and medicine.
"Right here at this point I'm looking at the new flag flying up there at the border. The rebels have got control of it, the freedom fighters. We're just in the process of opening it up," rebel Akram el Muradi said by telephone.
After nightfall, Gaddafi's forces resumed their bombardment of the post in an apparent attempt to return and the government said it had regained control over the Libyan side of the border.
The main crossing into Libya, two hours' drive to the north, remains firmly under Libyan government control.
Friday's clashes marked the first time government ground forces had crossed the border and entered a Tunisian town.
Inside Libya, NATO air strikes hit Gaddafi troops attacking rebel-held Zintan, a rebel spokesman said from there. But that did not stop the loyalists from firing 20 rockets into the city later in the day, the spokesman said.