An off-duty Border Patrol agent was holding a gender-reveal celebration for his wife’s pregnancy last year when he accidentally started a 47,000-acre wildfire, his attorney said.

The incident will cost Dennis Dickey $220,000 in restitution after he pleaded guilty Friday in federal court to a misdemeanor charge of causing a fire without a permit.

Nearly 800 firefighters from various agencies battled the Sawmill Fire for about a week in April 2017, at a cost of about $8.2 million.

The wildfire began when Dickey shot a target that contained Tannerite, an explosive substance designed to detonate when shot by a high-velocity firearm, U.S. Forest Service Special Agent Brent Robinson wrote in an affidavit filed Sept. 20 in U.S. District Court. The explosion was caught on film by a witness.

Tannerite is a legal compound that has been linked to wildfires in several other Western states.

The explosive target was part of a celebration of his wife’s pregnancy and contained colored powder to show the gender of their baby, blue for a boy or pink for a girl, Dickey’s attorney Sean Chapman told the Arizona Daily Star.

“Dickey immediately reported the fire to law enforcement, cooperated, and admitted that he started the fire,” Robinson wrote in the affidavit.

Under his plea agreement, Dickey will pay $100,000 in restitution when he is sentenced Oct. 9 and another $120,000 in monthly installments of $500 for the next 20 years. Dickey also will be sentenced to 5 years of probation.

"It was a complete accident," Dickey, 37, told U.S. Magistrate Judge Leslie A. Bowman Friday in court. "I feel absolutely horrible about it. It was probably one of the worst days of my life."

Chapman said Dickey will borrow from his retirement fund to pay the $100,000 due at sentencing. Ordering Dickey to pay $8.2 million to cover the cost of the fire would have been “like getting blood from a stone” because he could never come up with that much money, Chapman said.

Setting the fire was not a willful act, which meant he couldn’t be charged with arson, Chapman said. The charge was a petty offense and Chapman said he expected Dickey likely would keep his job as a Border Patrol agent.

The fire was started by Dickey on state-owned land near Madera Canyon. It spread across the Santa Rita Mountains foothills to Forest Service and Bureau of Land Management land, including portions of the Empire Ranch. At its peak, the fire forced the closure of Arizona 83.

At the time Dickey shot the explosive target, winds were gusting up to 40 mph and the National Weather Service had issued a fire watch, Chuck Wunder, chief of the Green Valley Fire Department, told the Arizona Daily Star in May 2017. A fire watch is a red flag, warning that “conditions are ideal for wildland fire combustion and that there is potential for rapid spread,” Wunder said.

No injuries were reported from the fire and no buildings were destroyed, but some households in the Greaterville and Singing Valley areas were evacuated. At times, hundreds of homeowners were under pre-evacuation orders.