For more than two years, they have tried to work it out. He went to their place, they came to his. There were moments of hope, but mostly there was strain and heartbreak — the phone call that wasn’t returned, the name-calling on national TV.

Now, once again looking for a way to repair his reality-show relationship with Republicans, President Obama is making the most basic of gentlemanly gestures: a fancy dinner, a lunch date and a promise to come over next week.

Obama is changing course to reset his relationships with Republican lawmakers, hoping for a last chance of breaking Washington’s gridlock before becoming a lame-duck president.

Obama wants to cement his legacy with a long-term deal to rein in the federal deficit and new immigration and gun laws, his advisers said. But his reelection victory, which brought a humiliating GOP defeat, has done little to break the logjam on taxes and entitlements.

Now, advisers said, the president has concluded that the key might be to bypass talks with Republican leaders — an avenue that has proved fruitless — and instead find common ground with rank-and-file Republican lawmakers.

Senator Bob Casey says the House bill to avoid a government shutdown is a bad idea and discusses his proposal to expand early childhood education. (The Fold/The Washington Post)

So the president is in the midst of a charm offensive. Wednesday, he treated a dozen GOP senators to a dinner of hamachi tartare, lamb and lobster. Thursday, he invited House Budget Committee Chairman Paul Ryan (Wis.), who just four months ago was on the Republican ticket to replace him, to his private White House dining room for lunch. Next week, Obama will take a rare drive to Capitol Hill to meet with all lawmakers.

“This is turning a page,” said Robert Gibbs, a former White House press secretary and longtime Obama adviser. “I think it’s a realization that, regardless of the outcome of the election, Republicans still aren’t in a position to change their tactics. It wasn’t like the loser loses. We had an election, and nothing really changed.”

House Speaker John A. Boehner (R-Ohio) said Thursday that he welcomed Obama’s outreach, even though it means the president is sidestepping him and other party leaders.

“We went through months of campaign-style events all over the country,” Boehner told reporters. “It’s really kind of interesting that this week we’ve gone 180. After being in office for four years, he’s actually going to try to talk to members. . . . I hope something will come out of it.”

But Boehner warned that unless Obama gives up on new tax dollars in a deficit deal, “I don’t think we’re going to get very far.”

Obama’s entreaties could all be for show. Even so, the president’s hand could be strengthened if the public concludes that the man who as a candidate once promised to bring Washington together is seen as having made sincere and humble efforts to bridge divides.

The White House insists this is an earnest effort to achieve a “grand bargain,” but aides say they are realistic about expectations.

“We are not naive about the fact that there are real disagreements between the two parties on these issues,” White House press secretary Jay Carney told reporters Thursday.

Since he arrived in Washington as a young senator in 2005, Obama has often been seen as aloof. As one longtime senior Democratic aide said, he just didn’t take to the place.

After Obama became president, he initially tried to build connections with lawmakers. He hosted them at cocktail parties, movie screenings and even a basketball game. But he established few lasting ties. His allies and opponents alike complained that he was too insular and detached.

In November 2008, two months before moving into the White House, Obama invited his vanquished Republican opponent, Sen. John McCain (Ariz.), and McCain’s trusted compadre, Sen. Lindsey O. Graham (S.C.), to meet with him in Chicago. The three sat around a coffee table in Obama’s transition headquarters, chewing over ways they might work together.

But over the next four years, there was little trace of partnership. McCain and Graham became two of Obama’s more vocal critics. Big deals proved elusive. Frustration on both sides escalated.

So it was that last week, Obama called on McCain and Graham to help him repair his relationships. At Wednesday’s dinner at the Jefferson Hotel, Obama sat between them, and they and other invited senators emerged hopeful that the polarizing dynamic was shifting.

“I think the American people would be heartened if they could have been a fly on the wall,” Sen. Ronald H. Johnson (R-Wis.) said. “It was a very pleasant, very genuine meeting. There was no contention. We all shied away from that.”

The senators generally praised Obama for the substance and depth of the conversation; there was only five or 10 minutes of small talk, they said.

“Where this goes, I have no idea,” Graham said. “But there was a common belief that entitlements need to be reformed and the tax code needs to be modernized — and the details may trip us up.”

Obama was emphatic on one point: The time for a deal is now. The White House sees this as an opportune moment both because the regular budget process is beginning in the Senate and House and because there is no immediate deadline pressure on both parties to act.

The pressure could return by midsummer, when the federal government again will reach its debt limit and Congress must vote whether to raise it or default.

Senate Democrats are surprised that Obama did not begin his outreach immediately after the November election, aides said. They worry that there may not be enough time before the debt-ceiling debate.

Obama wants to replace the across-the-board spending cuts that went into effect last week — known as the sequester — with a “grand bargain” budget deal. Obama has proposed finding savings in Medicare and Social Security in exchange for raising nearly $600 billion in new revenue by rewriting the tax code.

At Wednesday’s dinner, attendees said, Obama was specific about his ideas. He laid the same framework of spending cuts that he offered to Boehner in December in their negotiations to avert the year-end “fiscal cliff.” Obama’s offer included more than $500 billion in cuts to health programs in addition to the new revenue from capping tax deductions and eliminating loopholes.

Attendees said the president also endorsed a new way to calculating inflation that would result in reducing Social Security benefits over time — something many Democratic lawmakers strongly oppose.

“It was a full discussion,” Johnson said. “It was frank. It was honest. It wasn’t a negotiation. It was just really everybody sort of laying out the reality of what the situation is in terms of the issues we have to talk about.”

Yet within minutes after the dinner broke up, there was a stark reminder of how difficult it will be for the president and Republicans to find agreement. Johnson and two other attendees, Sens. Patrick J. Toomey (R-Pa.) and Saxby Chambliss (R-Ga.), shuttled from the Jefferson back to the Capitol. A filibuster was underway over the Obama administration’s drone policy, and they wanted to join in.

Discuss this topic and other political issues in the politics discussion forums.