BBC Americas Editor in Miami
Trade ministers from Latin America, the US and Canada meeting in downtown Miami to discuss a Free Trade Agreement of the Americas have wrapped up proceedings a day early.
A heavy police presence surrounded the talks
They were due to sign a final declaration on the deal on Friday, but caught everyone off guard on Thursday evening when they announced they had reached an agreement ahead of schedule.
The Free Trade Agreement of the Americas is due to come into effect by 2005, and would stretch from Alaska to Patagonia covering a population of 800 million and a combined GDP of $14 trillion (£8.38 trillion).
The participating countries had hoped to have a framework of a deal in place by the end of this year, but less than a week ago the summit looked like it might have collapsed through lack of consensus.
The two co-chairs of the negotiations, Brazil and the US, were keen to avoid a repeat of the failed World Trade Organisation talks in Cancun in September.
Yet they were still opposed over the very same issues.
Washington refused to discuss Brazilian demands for an end to US agricultural subsidies and full access to the American market in Miami.
Brazils Celso Amorim and Amerias Robert Zoellick met before the talks
Consequently Brazil said it would not consider issues the US wanted including in a free trade deal, such as investment flows and intellectual property rights.
The two held a series of emergency meetings in the run-up to the Miami summit.
And on the first day of official talks here, they announced a proposal for a flexible trade deal which would establish a set of basic rules but allow countries to opt in or out of additional clauses.
Chile, Canada, and Mexico were quick to express their discontent.
These three countries say they have already made significant concessions in order to secure free trade deals with the US, and think everyone should have to make the same degree of commitment.
During the week there was a flurry of diplomatic activity, with the US and Brazil -- rather surprisingly -- joining forces to convince the others to come on board.
Trade ministers from the 34 participating countries joined the summit on Thursday.
They had been set to hold a press conference and formal event to sign a declaration on the free trade deal at noon on Friday.
But it seems they have managed to agree to the idea of a flexible free trade agreement ahead of schedule.
There is still a lot of work to be done before a free trade zone of the Americas becomes a reality, but according to the delegations in Miami, they are a step closer to this goal.
With all the intense discussions going on the inside the security zone, the trade ministers were largely oblivious to events on the outside.
Arrests were made amid voilent clashes outside the Miami talks
For several blocks around the venue of the trade summit, massive iron barricades and hoards of police kept the public at a distance.
Armed riot police with shields lined the streets, armoured personnel vehicles could be seen on corners, helicopters constantly buzzed overhead and the local coastguard had several speed boats patrolling the waterfront where the trade summit was taking place.
Earlier in the week, police spokesman Lieutenant Schwartz told the BBC they had been preparing for the summit for more than six months and had even held meetings with the main protest groups to coordinate their actions in advance.
Both were keen, he said, to keep out the anarchists who might cause trouble.
His position was echoed by Fernanda Castejon of Oxfam International, who says the problem when things turn nasty during these sort of protests, is that the real message gets lost.
The authorities here in Miami did not want to see a repeat of the millions of dollars of damage caused when protests turned violent during the World Trade Organisation talks in Seattle back in 1999.
This was the first international trade meeting to be held in the US since the Seattle talks, and the Miami police were taking no chances.
But on the whole the demonstrations have been smaller than expected.
On Thursday, a number of arrests were made after violent clashes between police and protestors, which officials blamed on anarchists who had infiltrated legitimate demonstrations.
In separate incidents officers fired tear gas and pepper spray, and wielded wooden batons to disperse groups of demonstrators holding spontaneous protests.
An organised march later in the day, however, passed relatively peacefully.
Protesters believe the free trade deal will not be life-changing
Several thousand union workers, anti-globalisation supporters and environmental activists, carrying huge banners and paper mache puppets, walked through downtown Miami chanting: "FTAA, No Way."
One of the protestors told the BBC a region-wide free trade deal would have serious impacts on the livelihoods of communities throughout the Americas.
Others said it would lead to job losses and environmental damage.
The general feeling was that the FTAA would do nothing to change the lives of the poor in Latin America or the United States.
With the trade summit having wrapped up a day early, the fewer than anticipated protestors in town are also expected to start heading home - raising the question for some as to whether the authorities here went overboard in their preparations.