A Border Patrol agent pleaded guilty to starting an Arizona wildfire by shooting a rifle at a target intended to reveal the gender of his baby.

Dennis Dickey, 37, of Tucson, Arizona, pleaded guilty Friday to causing the Sawmill Fire, which torched swaths of Coronado National Forest, federal land administered by the U.S. Forest Service, and caused more than $8 million in damage, according to the U.S. Attorney's office.

Dickey accidentally started the fire by shooting a target filled with a color substance, which would burst out in pink or blue, depending on the sex of his and his wife's child.

Gender-reveal events, which have grown in popularity over the last decade, according to The Washington Post, typically involve parents popping balloons, cutting into cakes, or doing other everyday tasks that reveal the color pink or blue, indicating the sex of their baby.

But Dickey's target also contained Tannerite, a highly explosive substance, and he shot at it, the explosion sparked the fire that spread for thousands of acres. Nearly 800 firefighters worked to contain a blaze that engulfed more than 45,000 acres in flames over the course of a week in April 2017, according to Tucson.com.

Dickey's attorney did not immediately respond to a request for comment; the baby's gender was not immediately clear.

As soon as the explosion triggered the fire, Dickey, a U.S. Border Patrol agent, who was off-duty at the time, called the police and admitted to starting the fire.

In pleading guilty, Dickey agreed to five years of probation and more than $8.1 million in restitution with an initial payment of $100,000.

Although he agreed to the $8.1 million restitution sum, it's unclear if Dickey will pay the total amount. Local reports suggested Dickey will pay $500 a month for the next 20 years, for a total fine of $220,000. It was also unclear what will happen after the 20-year period.

Dickey also agreed to star in a public service announcement with the U.S. Forest Service, according to a news release.

He will be sentenced on Oct. 9, according to the U.S. Attorney's Office of the District of Arizona.