Shots were fired in the shadow of Knocknarea Mountain, Co Sligo, early yesterday, at gardai who responded to an emergency alert.
The incident led to a 13-hour siege as armed gardai surrounded a bungalow that contained a man armed with a single-barrel shotgun.
It ended when a 30-year-old man walked out the back door with his hands up. Nobody was injured.
A Garda spokesperson said: "When he agreed to surrender he was told to leave the single-barrel shotgun inside the house and come out with his arms raised. He was faced by a number of armed officers when he exited the building."
A garda helicopter flew overhead during daylight hours and an ambulance and the fire services also responded.
The houses of up to 40 neighbours, including several children, were evacuated as gardai sealed the scene off.
The alert was raised at about 12.30am when neighbours heard shots in a house at Scardenmore, on the Strandhill Road about 5km from Sligo town.
A Garda statement said neighbours alerted them to "suspicious activity".
But a spokesperson agreed: "They heard noises and they could have sounded like gunfire."
On arrival at the scene at Scardenmore, about 4km from Sligo town on the Strandhill Road, uniformed gardai noticed damage to a patio door. They then observed a male in his 30s in the house carrying a firearm.
Gardai said: "The male discharged the firearm in the direction of the gardai. One shot hit the patrol car on the passenger side."
When the armed regional response unit arrived, the man discharged further shots towards them. The gardai returned fire. Nobody was injured.
When the siege ended shortly after 1.30 pm yesterday, the arrested man was taken into custody at Sligo garda station.
Armed gardai at the scene carried high-powered weapons including Heckler & Koch MP7 machine guns.
Neighbours woke up to see them putting on bullet-proof vests and loading their guns.
Initially, they told neighbours they were on a training exercise.
A Garda spokesperson said: "There would have been a serious attempt to keep the neighbours calm. The preservation of life was the utmost priority."
For several hours, there wasn't a sound from inside the house as gardai maintained their siege.
There were garda siege negotiators at the scene. For hours, the conversation was one-way as the gunman listened but didn't respond.
Gardai also made several attempts to contact the man's parents, who were in Dublin at Leopardstown Races.
One woman with four children who was moved in the evacuation said: "We didn't know what was happening.
"When we saw all the blue lights at first we thought it might be a traffic accident.
"They [the gardai] eventually told us there was an armed man in the area."
Most of the families from the evacuated homes in the area moved to stay with relatives and friends.
Gardai sealed off the road for 2km and there were traffic diversions.
Retired Sligo town clerk John MacNabola, one of those trapped in his home inside the security cordon, said: "People were initially a bit frightened at first but as the day progressed things seemed to settle down."