A serial firebug in a skirt and sneakers went on an arson spree in Brooklyn and Manhattan, lighting more than 20 small blazes at churches, apartment buildings and parked cars and other spots over a fiery three-hour stretch, the feds allege.

Bryan Oviedo, 32, was caught on video setting a blaze at the Church of St. Luke and St. Matthew in Clinton Hill and trying to torch a four-story apartment building in Prospect Heights while its occupants slept during the Aug. 20 spree, federal prosecutors in Brooklyn alleged Monday.

Oviedo’s been linked by video footage to a score of other fires, all between 3 a.m. and 6 a.m. that day, prosecutors allege. Federal authorities took Oviedo into custody over the weekend, and the suspect is slated to be arraigned Monday in Brooklyn Federal Court.

Oviedo has a Brooklyn address but may be living on the streets, a law enforcement source said.

Footage shows the arsonist, who appeared to be dressed in a distinctive skirt and sneakers leaning into a trash can on the porch of the Church of St. Luke and St. Matthew on Clinton Ave. near Atlantic Ave. between 4:30 a.m. and 4:45 a.m., according to a criminal complaint.

A fire suddenly emanated from the trash can, then Oviedo put a lid on the can to partially cover it before walking away, the feds allege.

At about 5 a.m., two cameras from outside the Prospect Heights apartment building, on Pacific St. near Underhill Ave., about a fifth of a mile away from the church, showed someone in the same outfit, with a garbage bag in his hands, the feds allege. The suspect can be seen piling items in front of a porch there, the feds say. Moments later, the pile caught fire.

Cameras at the Clinton-Washington Aves. C train subway stop in Clinton Hill, and inside a C train, caught a clear shot of the suspect’s face between 5:15 a.m. and 5:45 a.m., the feds allege.

An NYPD officer who knew Oviedo from a July criminal mischief arrest recognized the suspect, leading to the ATF making an arrest over the weekend.

“As alleged in the complaint, Oviedo went on a predawn spree in residential neighborhoods in Brooklyn during which he set fire to multiple buildings, including a church and a residential building, while families slept inside, endangering lives and causing first responders to race to the scenes of these arsons,” U.S. Attorney Joseph Nocella said Monday.

If convicted of a federal arson charge Oviedo could face a mandatory minimum of five years in prison and a 20-year maximum sentence.