An off-duty Border Patrol agent celebrating his wife’s pregnancy last year accidentally started a 47,000-acre wildfire that took nearly 800 firefighters to extinguish, his attorney and federal authorities said.

Dennis Dickey, 37, of Tucson, Arizona, pleaded guilty on Friday to igniting the Sawmill Fire, which caused more than $8 million worth of damage in April 2017 when the off-duty Border Patrol agent shot a target containing Tannerite, a legal but highly explosive substance designed to detonate when shot by a high-velocity firearm, according to the US Attorney’s Office in Arizona.

The target was part of Dickey’s pre-planned celebration to announce the gender of the couple’s child and contained blue powder for a boy and pink powder for a girl, Dickey’s attorney, Sean Chapman, told the Arizona Daily Star.

“It was a complete accident,” Dickey told a judge Friday. “I feel absolutely horrible about it. It was probably one of the worst days of my life.”

As part of Dickey’s plea agreement, he will pay $100,000 in restitution upon sentencing on Oct. 9. He’ll also pay monthly $500 installments for the next two decades and be sentenced to five years of probation.

Dickey, who is expected to keep his job as a Border Patrol agent, will borrow from his retirement fund to pay the restitution, according to Chapman, who added that ordering his client to pay $8.2 million to cover the total losses attributable to the fire would have been like “getting blood from a stone.”

Dickey admitted firing the shots on April 23, 2017, that started the blaze on state-owned land that damaged more than 45,000 acres, including parts of the Coronado National Forest, federal authorities said.

Winds had been gusting around 40 mph at the time and the National Weather Service had issued a fire watch, the Arizona Daily Star reported in May 2017. No injuries were reported, but hundreds of people were ordered to evacuate, according to the newspaper.

Dickey, who has pleaded guilty to a misdemeanor violation of US Forest Service regulations, immediately reported the fire to law enforcement and cooperated with investigators, federal authorities said.

The gender of Dickey’s child was unclear. Calls seeking comment from Chapman were not immediately returned Monday.