NEW YORK, JULY 10 -- The 3,186 tons of garbage rotting aboard a barge for nearly four months will be burned and buried on Long Island, ending its 6,000-mile search for a home that took it from New York to the Bahamas and back, officials said today.

The town supervisor of Islip, from which the garbage first set out on its hunt for a dump March 22, said officials agreed that the trash will be burned at a Brooklyn incinerator and the ash buried at the Islip Town landfill on Long Island.

"I'm very happy with this solution," Islip Town Supervisor Frank Jones said. "It puts the garbage barge behind us."

The saga of the wandering trash barge caught the nation's attention as officials battled over what to do with it. The garbage, anchored in Gravesend Bay off Brooklyn, was turned away from five states and three nations during its Atlantic Ocean odyssey. It returned to its origin May 16 to face lawsuits and political bickering over its fate.

An agreement was reached during a six-hour meeting today of Jones, Commissioner Thomas Jorling of the state Department of Environmental Conservation and Commissioner Brendan Sexton of the city's Department of Sanitation.

"The agreement to take action by the city, town and state was occasioned by the inability of the responsible private parties, whose original business deal went sour, to resolve the problem on their own," Jorling said in a statement after the meeting at the Environmental Conservation Department in Queens.

The solid waste is expected to arrive at the southwest Brooklyn incinerator on Gravesend Bay by the middle of next week.

Vito Turso of the New York City Sanitation Department said it will take about 10 days to burn the garbage, which will yield about 400 tons of ash. Then the ash will be delivered in covered trucks to Islip.

Jones said Islip Town will receive a $40 "tipping" fee for each of the 400 tons of ash buried in the landfill. He said the fee will be paid by Harvey Gulf, International, the Louisiana firm that owns the Break of Dawn, the tug that towed the barge on its voyage to nowhere, Review Avenue Enterprises of Long Island City, the company that baled the refuse, and others.

During its 6,000-mile voyage, the barge and tug were rejected from ports in North Carolina, Louisiana, Alabama, Mississippi, Florida, Mexico, Belize and the Bahamas.