Armed officers and negotiators were called to Cynwyd, near Corwen, as North Wales Police closed part of the area at 21:45 GMT on Wednesday.
Police said a man in his 20s barricaded himself into a property and threatened officers with a firearm during the incident.
Ysgol Bro Dyfrdwy was closed due to the "serious incident".
Police asked motorists and residents to avoid the area before issuing an update after 09:00 GMT on Thursday to say a man had been taken into custody.
Supt Steve Williams said: "I would like to thank the residents of Cynwyd for their cooperation and especially the head of Ysgol Bro Dyfrdwy who agreed to close the school and to contact parents and staff."
A man is in police custody following an armed standoff in a Denbighshire village overnight.