A government shutdown could be justifiable in certain circumstances, Treasury Secretary Steven Mnuchin said Tuesday.

"At times there could be a good shutdown, and at times there may not be a good shutdown," Mnuchin said at a Senate Budget Committee hearing.

Mnuchin was responding to comments that President Trump made via Twitter in May, when he said that a "good 'shutdown'" was needed to respond to Democratic resistance to his agenda.

The administration's goal is not to shut down the government, and it would never allow a shutdown of the government's critical infrastructure, Mnuchin said.

Nevertheless, "there could be reasons at various times where that's the right outcome," he said.

The treasury secretary was responding to questions from Sen. Tim Kaine, D-Va., who commented that federal employees in his state faced uncertainty in 2013 when congressional clashes over government spending and Obamacare funding led to a partial two-week shutdown.