It was just a few days after a polar bear had mauled two people in the centre of town that the patrol officer pulled up by the school and scanned his binoculars along the rocky shoreline of Hudson Bay looking for any signs of a telltale white lump.

"There could be a bear, or several bears, right there hiding in the willows and you wouldn't even know it," said Bob Windsor, the officer for Manitoba Conservation. He had received three reported sightings in town that morning; there could be up to 20 on a typical November day.

Such is life in Churchill, a town with about as many polar bears as people.

But living with polar bears is growing more risky, for both species, in a future being written by climate change. The loss of sea ice has already caused a precipitous drop in the bear population around Hudson Bay, forcing bears off their platform for hunting seals – their main source of food.

The ice season in Hudson Bay has fallen by about one day each year over the past three decades, interrupting the polar bears' prime feeding season in the spring and keeping them off the ice longer into the autumn and winter.

Scientists say the starving bears are resorting to risky and atypical behaviours, such as cannibalism, and are wandering far inland, where they come into closer proximity with people in the small communities across the north.

For Windsor, who has a bandolier of shotgun shells slung around the seat of his truck, meeting a bear is all in a day's work. The officer, equipped with scare pistol armed with blanks, an array of firecrackers, an air horn and a paintball gun, spends his nights and days herding polar bears out of town and back on to the tundra.

"The bears that we deal with in our programme, we are teaching them to be scared of people," Windsor says. "Every bear that we chase, maybe we are helping out somebody down the line that encounters a bear, because it recognises that that's a person – and that is something to be scared of."

But Windsor's job is expected to grow more difficult with a warming Arctic. Local people in Churchill, and aboriginal hunters in the self-governing territory of Nunavut, report a rise in sightings of bears near communities in recent years.

Most encounters between the people of Churchill and the polar bears have been near misses – like the case of the woman who threw a bag of groceries at a bear to chase it away, and a man who distracted a bear from his two young children by swatting the animal with a dog leash. By the first week of November, there had been 168 such harmless incidents in Churchill this year. Most of those bears were sub-adult males. "Think of them as teenagers," said Daryll Hedman of Manitoba Conservation. "They are the ones that seem to get themselves into trouble."

Polar bears playing in Hudson Bay. Photograph: Rex Features

About a dozen polar bears that had been caught in town and resisted officers' efforts to chase them away were confined to a polar bear jail until they could be returned to the wild.

But in the pre-dawn hours of 1 November, an intruding polar bear ripped the ear of a young woman making her way home from a Halloween party and then pounced on a neighbour who came to her rescue, badly lacerating his head and torso.

The attack occurred in front of a dozen onlookers, who screamed, banged pots and pans, let off firecrackers and shot at the bear repeatedly – without effect. "My heart was pounding out of my chest," said Didier Foubert-Allen, another neighbour. "I shot at the bear maybe four times when I realised it was not going anywhere."

The bear,now streaked with blood, ran off only when Foubert-Allen ran for his truck and charged the bear with lights blazing and horn blaring.

Scientists predict a rise in such encounters across the north, with the melting of the sea ice. Wildlife managers across the polar region are already planning for a future of rising encounters between polar bears and humans.

The governments of America and Norway are working to assemble a database of bear attacks across all five polar range territories – Alaska, Canada, Greenland, Norway, and Russia – in anticipation of a rise in such conflicts.

To date, there are 110 recorded instances of polar bear attacks causing severe injury. James Wilder, the US fish and wildlife agency biologist overseeing the registry, said that number should be set against the "thousands and thousands – probably tens of thousands – of nonviolent encounters with polar bears" across the north.

Until this autumn, Churchill had a fairly peaceful history of living with polar bears, with only two recorded fatalities attributed to attacks from the creatures since 1717.

Conservation officials in Churchill and Nunavut are working on early-warning systems for intruding polar bears, such as radar or sophisticated ear tags. Last year, officials in Churchill fitted one of the town's worst nuisance bears – an adult male known locally as Lardass – with an ear tag fitted with a VHF transmitter.

One of many polar bear alert warning signs in Churchill. Photograph: Paul J Richards/AFP/Getty Images

The device was designed to send a text message to conservation officials if Lardass wandered towards town, allowing the bear patrol to intercept the repeat offender. However, the tag fell off and the bear patrol lost track of Lardass until late September.

Some American polar bear scientists have proposed Churchill residents make greater use of bear spray. Such irritant sprays are commonly used in wilderness areas of Alaska and other places where there is a risk of running into grizzlies.

Officials and conservation groups are also revisiting the once taboo notion of taking adult bears who are repeat offenders to the zoo, rather than killing the animals to reduce the risk to humans. The notion would upset the idea of only consigning orphaned cubs to a lifetime in captivity, and remains highly controversial.

"It is not know how well an adult bear would adapt to a captive life but in this situation where the choice is death by euthanasia, maybe it's a reasonable thing to try to see if it could be happy in a captive setting," said Geoff York of WWF.

But authorities are increasingly going to have to confront such difficult situations, as melting sea ice forces polar bears off their traditional platforms for hunting seal on to dry land. The decline of the sea ice and the shortage of food are cutting into the birth rate for female polar bears, threatening the survival of cubs and leading to strange or dangerous behaviour.

"Where really good research has been done, we find bears that are nutritionally stressed or otherwise desperate will try things that are risky," said Tom Smith, a wildlife biologist at Brigham Young University who studies human-bear interactions.

Researchers have seen evidence of cannibalism, which was previously unknown, and greater movement inland by polar bears, which ordinarily stay within five miles of the coast. There had been at least one recent incident of a polar bear travelling as far as 250 miles inland in search of food, Smith said.

The most dangerous behaviour of all, however, may be coming into contact with humans. Scientists expect that, too, to rise, as the polar bears are pushed off the ice. "When we see bears attacking people that is a very good sign that these are bears that are on the edge," said Smith.

For the moment, Churchill is holding its own. The town is seen as a model of human-polar bear coexistence. Children are trained in polar bear safety, and at the height of the season, Windsor and his colleagues are on 24-hour shifts.

But the polar bear alert programme Churchill is so proud of is operating on a tiny budget: just $95,500 (£59,000).

The authorities have already been forced to turn to tourists and television crews to "sponsor" expensive helicopter airlifts of animals from the polar bear jail back into the wild.

And so long as there remains seasonal ice in Hudson Bay, the town expects to continue seeing polar bears. Michael Spence, the mayor, acknowledges it is impossible to guarantee there will never be another polar bear attack in the town – especially in a future under climate change.

"You can't close every street. You can't fence the community," he said.

Encounters with polar bears were a fact of life, Spence said – even those that resulted in violence.

"The unfortunate part is, it is going to happen, because of where we live: we coexist," Spence said. "I think it's just like rolling dice: it will happen, but it's when it will happen."

• This trip was supported by Explore.org, Polar Bears International and Frontiers North