Police have arrested a man involved in an incident this morning in which shots were fired.
Avon and Somerset Police say the man was arrested in connection with a recent robbery in the Yeovil area.
Officers were called to reports of "what sounded like gunshots" in Castle Cary at about 1.30am.
They surrounded a property in the Park Street area containing a man with a gun.
After a three hour operation he eventually agreed to leave the property and was arrested – he is still in police custody.
A firearm was seized and will be forensically examined.
No-one was hurt during the operation – members of the public, police officers or the suspect.
Police say officers will continue to patrol the Castle Cary area to provide reassurance and receive information from members of the public.
There will also be a number of cordoned off areas in the town today including the High Street while crime scene investigations continue.
Superintendent Mike Prior, area commander for Somerset, said: “I know the incident in Castle Cary will be of great concern to the local community.
“During this incident, our officers were shot at a number of times and I can confirm that officer weapons were also fired as they attempted to protect themselves and members of the public, in what were extremely challenging circumstances.
“A man has now been arrested and thanks to the professionalism and bravery of our officers, no-one was injured.
“We’ll be maintaining a visible and reassuring police presence in the area and I’d encourage anyone with concerns to speak to their local neighbourhood team.
“We would like to thank the community for the way they have responded, showing patience and being very supportive while we carry out our enquiries.”