CHICAGO — Donald J. Trump’s feelings about Chicago couldn’t have been clearer. He loved the place.

It was 2004, and Mr. Trump, then a developer and reality show star, was waging a charm campaign here. He raved about Chicago’s “stunning” skyline and admired its architectural ingenuity as he proposed adding his own building to the mix. It was a “great city,” he said, right up there with his hometown, New York. Had Twitter existed at the time, Mr. Trump’s hashtag might have read #mykindoftown.

Oh, how his views have changed. In recent months, Mr. Trump has repeatedly — obsessively, in the view of some — commented on Chicago’s street violence in interviews, debates and off-hour social media outbursts. “Chicago needs help!” he wrote on Twitter recently, after lamenting the city’s “carnage” in an earlier missive and vowing to “send in the feds” to save the day. On Tuesday, after meeting with police union leaders at the White House, Mr. Trump once again took note of this city’s violence, saying “I always ask, ‘What’s going on in Chicago?’”

Politics could be partly to blame for Mr. Trump’s apparent change of heart. Chicago is Democratic to its core. It is where Barack Obama got his political start. And it is an easy foil when describing, as Mr. Trump does quite a bit, how dire urban America has become.

But personal pique may also be an important factor when it comes to Mr. Trump’s relationship with the city.

“It’s clear that he has a bone to pick with Chicago,” said Jesus G. Garcia, a Democratic Cook County commissioner.

During Mr. Trump’s campaign, Chicago’s tight-knit, high-dollar Republican establishment showed tepid support, and he wound up canceling a rally here before he even arrived on stage, citing the raucous protesters who had gathered at the scene. But it may be the rejection he faced when he brought in his grand dream of putting up the world’s tallest skyscraper that stings most of all.

After Mr. Trump enlisted one of the city’s top architectural firms, SOM, to build a shimmering hotel-and-condominium complex along the Chicago River, a Pulitzer Prize-winning architecture critic for The Chicago Tribune swiftly deemed an early drawing of the tower a “bloated blob.”

A new plan — well short of a world record — got better reviews, but Mr. Trump was still pushed by Mayor Richard M. Daley to add a spire that Mr. Trump viewed as expensive and unnecessary. “The mayor, in his way, made it clear that the spire was going to go on the building,” recalled Lee Bey, a former adviser to Mr. Daley.

And in 2014, long after Chicago had mostly accepted the 98-story Trump International Hotel and Tower and its nautical, curving walls near gems like the Wrigley Building, there came a final, surprise flourish: Mr. Trump’s name suddenly began appearing on the building’s side in shiny, two-story-high stainless-steel letters. Chicago groaned.

“I saw a big ‘T’ going up and thought, ‘Oh, they are not doing this,’” said Margaret Riordan, a native Chicagoan whose downtown condominium has a clear view of the letters. “As a general rule, it’s just considered bad taste to talk about your money, and certainly bad taste to be showy about it. That’s just not a Midwestern thing.”

Strains on the Campaign Trail

Tensions between Mr. Trump and Chicagoans escalated again in 2016, as Mr. Trump fought for the Republican nomination and thousands of people converged in the heart of Chicago in March to await his arrival.

Cars with license plates from Illinois, Indiana and Wisconsin inched their way into parking garages on the University of Illinois at Chicago campus. Hundreds of people poured out of an “L” station, many holding signs with anti-Trump slogans. Skirmishes broke out between Mr. Trump’s supporters and his opponents, who exchanged taunts and shoves.

Until then, Mr. Trump had made only tentative forays here as a candidate. For this rally, his campaign chose a venue that to some people seemed puzzlingly provocative: a university known for its diverse population of African-American, Muslim and Latino students.

Then an announcement was made before the candidate even appeared on stage: The rally was off.

But why it had been canceled was an open question. The local police said that the situation was under control and that they had not been consulted. Some here, irked by Mr. Trump’s suggestion later that his rights had been violated, speculated that it had always been his plan to call it off.

“I don’t want to see anybody get hurt,” Mr. Trump said on CNN that evening. “And you would have had some people possibly getting hurt, or beyond.”

After that, Mr. Trump mostly steered clear of Chicago. And Chicago — even some in the top echelon of the city’s establishment Republicans — largely steered clear of him.

In a city where outnumbered Republicans tend to stick together, some top donors who usually gather checks from their friends stayed home. When Steven Mnuchin, then Mr. Trump’s campaign finance chairman, approached William Kunkler, an influential Chicagoan who served with Mr. Mnuchin on the board of Sears Holdings Corporation, Mr. Kunkler was blunt.

“I can’t help you on this,” Mr. Kunkler, who had helped lead fund-raising efforts here for Mitt Romney, recalled telling Mr. Mnuchin, now the Treasury secretary.

“This is one Republican who is never jumping on that bus,” Mr. Kunkler reflected in an interview.

Ron Gidwitz, a stalwart fund-raiser among Chicago Republicans who led Mr. Trump’s efforts here, said plenty of Chicagoans did join his White House bid. He cited a fund-raising luncheon where several dozen people gathered inside Mr. Trump’s Chicago tower as Mr. Trump sought advice on his vice-presidential choices, then posed for photos with guests and the local security detail.

“They weren’t always the traditional Republicans I would normally go to first,” Mr. Gidwitz said. “But he brought out people you might not usually see.”

Elaine Conti — a Republican donor who was introduced to Mr. Trump at a hastily arranged meet-and-greet at the Polish National Alliance, a fraternal society on the Northwest Side — said that as he shook her hand, he asked her what she thought of Chicago.

“He let me know that he wants to fix it, the robberies, the killings,” she said. “He thinks Chicago is a mess.”

Translating Anger Into Action

Mr. Trump’s remarks about crime here began before his presidential bid. In 2013, he urged the use of “stop and frisk” tactics in Chicago, which he described as a “shooting disaster.” In 2014, he wrote on Twitter, “Obama should work on a cease-fire in Chicago as well as Gaza.” And in a presidential debate last fall, he likened the city to a “war-torn” country, announcing plainly, “It’s terrible there, what’s going on in Chicago.”

For some here, the attention is welcome. “I think he does really care about what’s happening,” said Garry McCarthy, a former Chicago police superintendent. The Rev. Ira Acree, who has bemoaned an increase in bloodshed near his West Side church, said, “If Trump can help Chicago, to hell with what his motives are.”

Yet others here dismiss Mr. Trump’s remarks as devoid of solutions and concrete federal help. They say the comments are aimed at alarming white, nonurban voters, and at landing political blows on a city that was home to Mr. Obama and is run by Mayor Rahm Emanuel, a Democrat who advised Mr. Obama.

Not so, said a spokeswoman for Mr. Trump, Sarah Huckabee Sanders, who wrote in an email: “The entire premise of your story is false and ridiculous. The president doesn’t have a disdain for Chicago, he has a disdain for senseless violence. No one can deny that Chicago has a problem with violent crime, and the president has made a commitment to return our country to a law and order country, not just in Chicago but in every city in America.”

Still, even as Mr. Trump has railed against Chicago’s violence, Attorney General Jeff Sessions has indicated that the administration will back away from monitoring troubled police departments like Chicago’s. Activists here say they worry that the White House, while fixated on the city, will focus less on forcing police reform, making it harder for the police to gain the trust in black and Latino communities that would help bring violent crime under control.

Interactive Feature | Deconstructing the ‘Ferguson Effect’ The idea that the police have retreated under siege won’t go away. But even if it’s true, is it necessarily bad?

Meanwhile, the pace of Mr. Trump’s comments has only picked up.

None of it has gone unnoticed by Mr. Emanuel, a leader who can be as loud and contrary as Mr. Trump. At first, his public response seemed uncharacteristically muted. He said he welcomed federal help in the form, for instance, of tougher gun prosecutions. But though Mr. Emanuel’s allies say he has sought such assistance, nothing has been announced.

“Donald Trump sees this more as a punch line than a true, top-of-mind concern,” said David Axelrod, a friend of Mr. Emanuel’s and former senior adviser to Mr. Obama.

Lately, Mr. Emanuel has sounded more testy, questioning last month “whether the president cares enough about violence in our city to do more than talk or tweet about it.”

Mr. Emanuel’s spokesman, Adam Collins, said Mr. Trump’s derision had been aimed not just at Chicago, but at urban America writ large. “What you don’t hear is him talking about the carnage in rural America that’s being caused by the opiate crisis gripping those areas,” Mr. Collins said. “One resonates with his political base, the other doesn’t.”

The mayor’s friends say he is acquainted with Mr. Trump through Mr. Emanuel’s brother, Ari, who once worked as Mr. Trump’s agent. But the two are at odds on many issues and did not meet until December, Mr. Collins said. Still, in 2010, Mr. Emanuel’s first mayoral campaign received $50,000 from Mr. Trump, who also gave to other Chicago politicians.

Lately, attention here has turned back to Mr. Trump’s signature tower. Protesters gather near its front doors. Tourists pose for selfies, some holding their middle fingers up with the Trump sign as a backdrop. On a chilly February afternoon, dozens of giggling people staged a mass mooning of the building from a plaza across the Chicago River.

Chicago is awash in honorary street signs recognizing individuals — high school football coaches, local ministers, funeral home directors. Mr. Trump got the special brown signs, too, granted by the city near his building as it was going up. But the City Council voted not long ago to undo Mr. Trump’s honor, one more rebuff in a long, tumultuous relationship.