Foreign Secretary Robin Cook said the contract was given approval because the United Nations said it did not damage the cease-fire in force in the region.
The government's own guidelines ban sales of weapons and spare parts where they might be used for internal repression or external aggression.
Anti-poverty group War on Want said: "We are very concerned that the UK government is endorsing arms exports from the UK to a disputed territory."
And Conservative foreign affairs spokesman Francis Maude said: "This news exposes Labour's threadbare claim to have an ethical foreign policy.
"They say one thing but do another."
There are between 80,000 and 100,000 Moroccan troops are deployed in Western Sahara.
The North African country has been engaged in a decade-long conflict with the Polisario Front independence movement.
The conflict remains unresolved, despite a UN-brokered ceasefire which has been in effect since 1991.
A Foreign Office spokesman said that in 1998, a British company - which he would not name - put in an application for a licence to sell parts for 30 guns.
Initial refusal
Although the application was initially refused because it would break rules on arms exports the company involved appealed.
That appeal was made on the grounds that the sale would be consistent with the UN mandate.
The UN then confirmed that such refurbishments were permitted, and that their peacekeeping force in the region would supervise the refurbishment process.
UN advice accepted
"We accepted the UN advice and granted the licence," the spokesman said.
On Wednesday, Mr Cook told a joint meeting of the House of Commons foreign affairs, defence, trade and industry and international development committees that the Western Sahara process had a "very well established and mandated UN presence".
"I think if they had resisted the application, we would have, on appeal, upheld our own refusal," he said.
"But the ground for our refusal was rather removed by the UN removing any objection to it."