AUGUSTA, Maine — State forestry officials signed an emergency order on Wednesday banning the importation of untreated firewood into Maine as part of a stepped-up campaign to prevent the spread of invasive pests wreaking havoc in other parts of the country and Canada.

As part of an educational campaign for the final weeks of camping season, state forest rangers will offer a free firewood exchange in Kittery this weekend to out-of-state campers who unwittingly violate the new rules.

“We’re not interested in being overly aggressive in this,” Alec Giffen, director of the Maine Forest Service, said Wednesday. “We recognize this is something that takes time to build awareness among people.”

The formal ban comes roughly five months after the Legislature passed a bill, LD 1607, directing state officials to develop rules to prohibit out-of-state campers as well as Maine residents from bringing firewood into the state.

The prohibition is primarily aimed at preventing the spread of two particularly destructive invasive bugs found within an easy driving distance of Maine’s borders: the Asian longhorned beetle and the emerald ash borer.

Asian longhorned beetles, which infest and kill a host of deciduous trees but could pose particular threats to Maine’s maple trees, have been discovered in Massachusetts, New York and New Jersey.

In Worchester, Mass., crews have removed more than 25,000 trees so far and designated roughly 70 square miles as an “eradication zone.”

The emerald ash borer, meanwhile, has been found south of Montreal as well as in New York, Pennsylvania, Maryland and several Midwestern states. The small, burrowing beetle is deadly to most trees it infects and has already killed tens of millions of trees in the U.S. and Canada.

Between 11 and 15 percent of Maine’s forest landmass is ash, so an outbreak in this state could have significant financial effects, Giffen said.

“It’s very important for us to be good stewards of this resource and to take all of the actions we can to protect it,” Giffen said of Maine’s forests.

Giffen and others acknowledged that the emergency order signed Wednesday arrives at the tail end of the summer season but said it took time to develop. But they pointed out that campers, tourists and hunters continue to flock to the state well into late fall.

“We think of this as being the end of the season, but it really isn’t. We take a break and then begin the next tour,” said Dave Struble, state entomologist. “And this really sets us up for next year.”

The order prohibits importation of firewood unless it has been certified as pest-free by the U.S. Department of Agriculture or analogous state or Canadian agencies. Additionally, all retail firewood sellers in Maine will have to provide documentation that their firewood either comes from Maine or is certified as pest-free.

Labor Day weekend campers willing to brave the possible effects of Hurricane Earl who cross over into Maine on Interstate 95 will be greeted with signs informing them of the new prohibition.

Maine Forest rangers will also be manning a station just off the Kittery exit where out-of-state campers can voluntarily swap their firewood for a similar quantity of Maine-grown firewood for free.

Park rangers and forest rangers throughout the state will also be reminding campers about the new rules and urging them to burn any out-of-state firewood within 24 hours.

“We want them coming to our state, and we want them to come and visit, but we want them to leave their firewood at home,” said Jeff Currier, a regional forest ranger for southern Maine.