WASHINGTON — Former President Jimmy Carter and the man he beat, then-President Gerald Ford, got so tight after office that their friendship became a kind of buddy movie, complete with road trips that were never long enough because they had so much to gab about.

Carter did not get along nearly so well with the other living presidents. The outsider president was an outlier after his presidency too.

Nevertheless, past and present occupants of the office will attend Carter’s state funeral this week in what could be the largest gathering of the presidents club since five attended Washington services for George H.W. Bush in December 2018.

As a member of that elite, informal club, Carter was uniquely positioned to do important work for his successors, whether Democrat or Republican. He achieved significant results at times, thanks to his public stature as a peacemaker, humanitarian and champion of democracy and his deep relationships with foreign leaders, troublemakers included.

But with Carter, you never knew when he’d go rogue. This was a man so self-confident, he described himself as “probably superior” to the other ex-presidents who were still knocking about. Ornery about taking orders, he could be invaluable to the man in office, exasperating, or both at once.

The others often bonded over “what an annoying cuss Carter could be,” Nancy Gibbs and Michael Duffy wrote in their book “The Presidents Club.”

“Carter was the driven, self-righteous, impatient perfectionist who united the other club members around what seemed like an eternal question: Was Jimmy Carter worth the trouble?”

He was, in the mind of Randall Balmer, a Dartmouth College historian of religion and Carter’s rise to the presidency. Balmer points to the violence averted in the last hours before a U.S. invasion of Haiti in 1994, when Carter, to the benefit of Democratic President Bill Clinton and countless lives saved, brokered a deal with Haiti’s military coup leader to step aside and restore democracy.

“Any time you can avoid military conflict you score that as a win,” Balmer said.

Four years earlier, for the benefit of Republican President George H.W. Bush and the lives at stake in the region, Carter secured peace in Nicaragua at the brink of bloodshed when he persuaded the leftist leader Daniel Ortega to accept the electoral defeat that had so shocked the Sandinistas.

John Danforth, former Republican senator from Missouri, joined Carter on missions to lay the groundwork for the 1990 Nicaragua election and then monitor it.

In the first, the Carter entourage came upon Ortega’s motorcade on a dusty road through the town of Rivas.

The two men retired to the backyard of the nearest house for an impromptu negotiation over the government trucks Carter wanted Ortega to send around the country to deliver election material.

“Often when we envision former presidents, the picture is distant, even stuffy: men in dark suits and neckties captured in formal poses as though engaged in deep thoughts,” Danforth wrote in the St. Louis Post-Dispatch in February 2023. “My picture of Carter is quite the contrary. He is in a back yard in Rivas. A crowing rooster is at his feet. An earnest expression is on his face. He’s not talking statecraft; he’s talking trucks.”

In January 2009, President George W. Bush invited other members of the presidents club to the White House for lunch and Oval Office photos. Bush, his father, Clinton and President-elect Barack Obama are seen clustered in front of the Resolute Desk. Carter is conspicuously off to the side — outlying.

The images spoke volumes about Carter’s place in the club, Balmer said. “Jimmy Carter didn’t fit in with a lot of people. He was really an introvert, not somebody who warms up easily.”

Democrat Lyndon Johnson leaned frequently on Republican predecessor Dwight Eisenhower, telling him, “You’re the best chief of staff I’ve got.” On the night of John Kennedy’s assassination, LBJ sought Ike’s advice on what to say to Congress, adding: “I need you more than ever now.”

Reagan once pulled Clinton aside to tell him the military salute he was executing during the campaign was too lame for the presidency. He taught him how to make it snappy. Clinton in turn cherished his long, frequent phone calls with Richard Nixon, confiding in the disgraced but savvy Republican on foreign policy problems of the era.

Clinton also became close to the Republican he vanquished in 1992, joining the elder Bush in Maine for golf, zippy boat rides and nights by the sea.

More consequentially, the younger Bush asked his dad and Clinton to lead a fundraising mission for countries devastated by the 2004 tsunami, giving rise to a bipartisan pairing that pitched in on more endeavors, like Hurricane Katrina relief.

“I just loved him,” Clinton said upon the senior Bush’s death in 2018.

So, too, Obama and the younger Bush have teamed up on occasion, and Bush enjoys a good-natured relationship with Michelle Obama.

But the Jimmy-Jerry friendship was one for the ages.

Carter took it as a point of pride when two historians, speaking separately at a commemoration of the 200th birthday of the White House, said his friendship with Ford was the most intensely personal between any two presidents in history.

Carter said it began in 1981, when the two were sent by Reagan to represent the U.S. at the funeral of Anwar Sadat, the assassinated Egyptian leader. Nixon was on the trip, too, somewhat awkwardly. The other two took to each other, commiserating over how tough it could be to raise money for a presidential library when you’ve been booted out of office.

They were both Navy men, had three sons, a strong religious faith that Ford was quieter about than Carter, and independent spouses who bonded as well. “The four of us learned to love each other,” Carter said.

Carter and Ford spoke regularly, teamed up as co-leaders on dozens of projects and decided together which events they’d attend and skip in tandem.

“When we were traveling somewhere in an automobile or airplane, we hated to reach our destination, because we enjoyed the private times that we had together,” Carter said.

That’s what he told mourners in January 2007, at a service for Ford the month after he died at age 93.

The Democrat and the Republican he so cherished had made a pact, one hard to imagine in this time of partisan poison: Whoever died first would be eulogized by the other.

But Ford’s eulogy for Carter is also part of Carter’s service.