In Europe and Africa, as in much of the rest of the world, 2017 was a year of political upheaval.

Emmanuel Macron, an inexperienced 39-year-old pro-Europe investment banker and ex-economy minister, ran as an independent and beat populist Marine Le Pen to become French president. Six months later, with German Chancellor Angela Merkel mired in a struggle to form a political coalition in her own country, he is increasingly taking a leadership role in Europe and beyond.

In Spain, Catalan separatists declared independence from the rest of the country after a referendum declared illegal by the Spanish government. People who tried to vote were met with police violence, protesters took to the streets, and the movement's leader fled to Brussels to avoid prosecution.

Negotiating the terms of Britain's exit from the European Union, meanwhile, was the key political preoccupation in Britain, where Prime Minister Theresa May's Conservative Party lost its majority in Parliament after she called an ill-advised snap election. She now leads a minority government deeply divided over Brexit.

Russian President Vladimir Putin solidified Russia's place in the world, exerting political muscle in Syria and elsewhere. He and U.S. President Donald Trump have been engaged in a delicate courtship despite sanctions imposed by each country on the other and a U.S. investigation into possible collusion between Russia and the Trump campaign.

Zimbabwe saw the extraordinary ousting of Robert Mugabe after 37 years in power as the military moved in, hundreds of thousands rallied in the streets and the ruling party began impeachment proceedings. The downfall began when the 93-year-old Mugabe fired his deputy and positioned his wife to succeed him; that deputy is now the new president.

Kenya saw months of deadly political turmoil as the Supreme Court nullified the presidential election, a first in Africa, and ordered a new vote that the opposition leader boycotted, saying electoral reforms had not been made.

In Europe, refugees and migrants continued to arrive, though in fewer numbers and with greater difficulty than at the height of the migrant crisis in 2015.

Aside from politics, 2017 was characterized by chaos and casualties inflicted by the Islamic State group and other extremists. Britain dealt with a series of attacks — in March, a man drove his rented SUV into pedestrians on London's Westminster Bridge, killing four, then stabbed a police officer to death. In May, a suicide bomber blew himself up after a pop concert, killing 22 people and injuring 116 others. Less than two weeks later, eight people died when three men crashed a van into pedestrians on London Bridge before rampaging through Borough Market with knives. Muslim worshippers also became targets during the holy month of Ramadan, mowed down by an attacker who plowed a van into a crowd leaving prayers at two mosques in north London.

Tragedy struck in June at Grenfell Tower, a 24-story public housing project in London that was engulfed in flames after a refrigerator fire quickly spread through the building. Seventy-one people died, touching off a national reckoning over shoddy construction practices and inadequate fire safety regulations.

In Spain in August, a van plowed into people walking along Barcelona's famed Las Ramblas, killing 13 and injuring dozens more. Attackers then drove to a seaside resort town and killed another person before five of them were shot to death. The Islamic State group claimed responsibility.

Somalia had its worst ever attack in October, when more than 500 people were killed by a truck bomb on a Mogadishu street. The government blamed al-Shabab, but no group has claimed responsibility.

The following is a selection of some of the best AP images from 2017 in Europe and Africa, curated by Europe and Africa Regional Photo Editor Tony Hicks.