When Dennis Dickey, a United States Border Patrol agent from Arizona, fired at a target filled with colorful powder, he was expecting to learn the gender of his future child, his lawyer said.

Instead, the target erupted and sparked a fire that consumed more than 45,000 acres of land and resulted in more than $8 million in damages, the United States attorney’s office for Arizona said.

On Friday, Mr. Dickey pleaded guilty to a misdemeanor violation of United States Forest Service regulations for igniting what became known as the Sawmill Fire, which started on April 23, 2017, and had nearly 800 firefighters battling it for about a week.

The fire began while Mr. Dickey was off duty near Green Valley, Ariz., about 26 miles south of Tucson, to celebrate his wife’s pregnancy, his lawyer, Sean Chapman, told The Arizona Daily Star.