In his second month as mayor of New York, just five months after September 11, 2001, Michael Bloomberg appointed his sister, Marjorie Tiven, to head what is now known as the Mayor’s Office for International Affairs—a position, she later told the Times, that entailed making sure that her big brother was “behaving in a way that doesn’t offend other heads of government.” From the start of his tenure, Bloomberg clearly foresaw an expanded role for the city, and for its mayor, on the international stage, but his degree of involvement in foreign affairs has been unprecedented for a municipal official—even one whose city is home to the United Nations.

Bloomberg chaired the Climate Leadership Group, an effort to reduce carbon emissions in fifty-eight of the world’s largest cities; he spoke at the World Bank in Washington, D.C., about bringing down the number of traffic injuries around the globe; and he became a leading voice on immigration reform, arguing for a more liberal allowance of visas for skilled workers. In 2007, he enlisted a former member of President Clinton’s National Security Council as his tutor in foreign affairs, and he later made official visits to Mexico, Ireland, Israel, Paris, and London. At a speech in Singapore, earlier this year, Bloomberg described a world where cities, rather than nations, are the major players in both global competition and innovative policymaking: “With three-fourths of the people on Earth expected to be city dwellers by mid-century, cities around the globe, including New York, must confront all the effects of this urban growth.”

Though Bill de Blasio, who will be inaugurated as the city’s hundred and ninth mayor tomorrow, campaigned as a fighter against economic inequality who would improve access to education and health care for New Yorkers, earlier in life he was more absorbed by international issues than domestic politics. He earned a master’s degree in international affairs at Columbia, and worked as a volunteer in Nicaragua, where he supported the socialist Sandinista government against the right-wing U.S.-backed Contras. While he was an aide in the Dinkins Administration, he helped to organize Nelson Mandela’s visit to New York, an experience, a de Blasio spokesperson told me, that showed the young politico how “the eyes of the world looked to New York City as a model for new understanding.”

In 2012, as the city’s public advocate, de Blasio introduced an Iran watch list, which urged New Yorkers to boycott automobile manufacturers who do business in the Islamic Republic. The program, undertaken in conjunction with two nuclear-sanctions advocacy groups, was seen as a move to score points with Jewish voters ahead of the mayoral race. But it also played well with another key constituency: the city’s taxi owners, who fiercely opposed Bloomberg’s so-called Taxi of Tomorrow initiative, which would have replaced all yellow cabs with a new model manufactured by Nissan—one of the companies targeted by de Blasio’s watch list. (The public advocate’s office even produced an image, designed to be shared on Facebook and Twitter, featuring Ahmadinejad waving from the passenger seat of a Nissan taxi.) “Local matters trump all,” de Blasio’s aide told me. “But he recognizes that New York has these other roles in international issues, too.”

Twelve years after the collapse of the Twin Towers, New York City still functions, perhaps more than ever, as the country’s “window on the world.” The rise and fall of its stock markets are taken as a proxy for the health of the U.S. economy; foreign capital pumps ten billion dollars each year into Manhattan commercial real estate, and businesses owned by new immigrants add another ten billion dollars to the economy. Last year, eleven million foreign tourists shuffled along the city’s sidewalks, and thousands of foreign dignitaries passed through the headquarters of the United Nations.

But the city’s most pressing “foreign” issue remains its response to the September 11th attacks: the New York Police Department’s counterterrorism program, which Bloomberg championed, and which de Blasio will inherit. In April, 2009, when Raymond Kelly, New York City’s Police Commissioner, made his second visit in four years to the Council on Foreign Relations, he emphasized the N.Y.P.D.’s “intensely international focus.” Many city officials regarded September 11th as a failure of federal agencies to keep the city safe, and Mayor Bloomberg tasked Kelly with creating the nation’s first municipal counterterrorism bureau. In part, that meant a closer relationship with the feds—the N.Y.P.D. increased its presence on the Joint Terrorism Task Force, headed by the F.B.I., from a half dozen to over a hundred officers—but it also meant launching its own operations. (William Finnegan wrote about the N.Y.P.D.’s ambitious counterterrorism efforts for the magazine in 2005.)

Kelly hired David Cohen, the former head of the C.I.A.’s spy division, to run the force’s intelligence outfit. Cohen, a trained economist known to be intensely loyal to his superiors (and profane with everyone else), created the Demographics Unit, which sent police officers to neighborhoods with large Muslim populations to observe mosques, restaurants, travel agencies, and other gathering places. At the same time, Kelly created the International Liaison Program, which posted detectives in eleven hot spots overseas, including London, Paris, Madrid, Abu Dhabi, and Tel Aviv. “We’ve reorganized the department to accommodate this world view,” Kelly said. “You might say that the N.Y.P.D. has aspired to become a Council on Foreign Relations with guns.”

Much of what is known about the N.Y.P.D.’s Demographics Unit and International Liaison Program can be found in the book, released this fall, “Enemies Within,” by the former Associated Press reporters Matt Apuzzo and Adam Goldman. (The pair won a Pulitzer Prize for their initial investigations into the N.Y.P.D.) To institute their ambitious programs, Kelly and Cohen sought to modify the Handschu agreement, dating from 1985, which prohibited the N.Y.P.D. from conducting open-ended group surveillance without evidence of a crime. A year after September 11th, Cohen successfully challenged aspects of the Handschu agreement in court, insisting that, owing to the new global threat, “to wait for an indication of crime before investigating is to wait far too long.” At the same time, Kelly appealed to the New York City Police Foundation, a nonprofit group backed by JP Morgan, Goldman Sachs, Barclays, News Corp., and Bloomberg, among others, to pay over a million dollars each year for the International Liaison Program. This unorthodox funding scheme allowed Kelly to avoid a lengthy debate in the city council on whether city tax dollars should be spent on the living costs of detectives stationed in foreign capitals. At one point, in a meeting with the Police Foundation, Kelly revealed his reasoning. “I don’t like to be told no.” he said. “So I just don’t ask.”

Some of the N.Y.P.D.'s more aggressive efforts have since created friction between the city and just about everyone else—its Muslim residents, its federal agencies, and its foreign allies. In 2005, two detectives stationed in London briefed their bosses about the Underground bombings that killed fifty-two people, and Kelly infuriated British law enforcement that evening, when he revealed details of the investigation at a press conference. On another occasion, Cohen tried to infiltrate the Iranian Mission to the United Nations with wired informants, and the Justice Department, concerned the officers would disrupt an ongoing federal investigation, considered charging Cohen with obstruction of justice. After the F.B.I. alerted the N.Y.P.D. that a Queens resident named Najibullah Zazi appeared to be planning a suicide bombing in the city, a detective in the Intelligence Division contacted a source in Zazi’s neighborhood; the source then called Zazi, who fled. (He was later arrested in Colorado.) “We fucked that up,” Cohen told an incensed chief of national security at the F.B.I.