In his days as mayor of Newark, Senator Cory A. Booker built a national image of himself as a model citizen, given to well-publicized acts of valor like helping his neighbors escape a house fire and saving a vulnerable dog from the bitter cold.

But at a recent event on Capitol Hill, Mr. Booker held up a different New Jersey politician as a paradigm of civic virtue: Robert Menendez, the state’s senior senator.

“I knew him well when I was a mayor, because every time Newark needed something, he would show up — sort of like a superhero,” Mr. Booker told a select audience at a breakfast hosted by the United States Hispanic Chamber of Commerce on March 25, about a week before Mr. Menendez, a fellow Democrat, was indicted on bribery charges.

Describing the “respect and reverence” he felt for his colleague, Mr. Booker hailed Mr. Menendez as “one of the greatest advocates for justice on the planet Earth.”

Mr. Menendez has enjoyed broad support from Democratic officials in New Jersey during his moment of crisis. But few, if any, have defended him as energetically as Mr. Booker, a junior lawmaker who has leaned on Mr. Menendez for guidance since joining the Senate in 2013.

If Mr. Booker relied on Mr. Menendez to help ease his arrival in Washington, Democrats say the relationship has been almost reversed: Now, it is Mr. Menendez depending on Mr. Booker to stand by him as he fights to keep his job.

In some respects, it is a peculiar role for Mr. Booker: A political celebrity who rose to high office flouting New Jersey’s entrenched Democratic establishment, and casting himself as a squeaky-clean outsider, he now finds himself vouching for Mr. Menendez, an avatar of the state’s rigid, unpopular power structure.

At a mid-March event in Englewood, N.J., with an indictment looming, Mr. Booker explicitly embraced the role of sidekick, praising Mr. Menendez’s work for the state and proclaiming himself “the Robin to his Batman.”

Reached by phone on Thursday, Mr. Menendez said he was “deeply touched” by the outspoken support he has received from Mr. Booker, whom he called an up-and-comer with “unlimited potential” and a gift for advancing the causes he believes in.

Among those causes, Mr. Menendez said, are criminal justice reform and the treatment of minorities in the judicial system.

“It’s obviously no secret that the last two weeks have been tough and I’m grateful for Cory’s unwavering support,” Mr. Menendez said. He described their working relationship as close and complementary. “We have different styles,” he said, “but our goals are exactly the same as it relates to the people of our state.”

Mr. Menendez and Mr. Booker have not appeared together since the 14-count indictment was handed down last week, accusing the veteran lawmaker of accepting bribes from a political patron and making false statements to investigators. Mr. Menendez has denied any wrongdoing.

Monique Waters, a spokeswoman for Mr. Booker, said the senator will keep working closely with Mr. Menendez irrespective of the continuing legal process. The two men spoke by phone on Thursday, and when Mr. Booker held a news conference in his home state this week, his office invited Mr. Menendez to participate — a supportive gesture, though the embattled senator was unable to attend.

“Senator Booker will continue to partner with Senator Menendez to take on the tough challenges facing New Jerseyans, and firmly believes in the rule of the law and its inherent presumption of innocence before guilt,” Ms. Waters said.

As political personalities, Mr. Booker and Mr. Menendez could hardly be more different: Mr. Menendez is a career legislator with a passion for foreign policy, a stern and introverted political operator with a tight grip on the New Jersey Democratic machine.

Mr. Booker, by contrast, is an ebullient communicator with a reformer’s reputation, an instinct for activism and relatively little interest in the minutiae of party building on the local level.

“He’s just very gregarious,” Mr. Menendez said. “I’m more reserved.”

There have been moments of political friction over the years. In 2002, when Mr. Booker made a daring and unsuccessful challenge to Newark’s longtime mayor, Sharpe James, Mr. Menendez, a congressman at the time, endorsed the incumbent. (Mr. James, a Democrat, subsequently served time in prison for corruption.)

Years later, as Jon S. Corzine, then the governor of New Jersey, faced a daunting 2009 re-election fight against Chris Christie, a Republican, Mr. Menendez was part of a group of Democratic leaders who urged Mr. Booker to join Mr. Corzine’s ticket as a candidate for lieutenant governor, as an act of loyalty to the party. Mr. Booker rebuffed their entreaties.

But if Mr. Booker made his way in New Jersey politics as a defiant upstart, he appears to have recognized that mastering Washington is a different matter entirely. Since he set his sights on the Senate, Mr. Booker has cultivated Mr. Menendez as a friend and ally, approaching their relationship with the emphatic humility of a newcomer seeking help from a practiced hand.

After the death of Senator Frank R. Lautenberg in June of 2013, Mr. Booker sought Mr. Menendez’s political blessing in a special election: He met with Mr. Menendez in Newark that summer and asked him to consider serving as his mentor, according to advisers to both men, who asked to speak anonymously about a private conversation.

The two men have regularly appeared together at events in the state and issued joint statements announcing achievements and policy goals. They have worked closely on issues related to Hurricane Sandy recovery, and the first foreign policy legislation Mr. Booker endorsed after joining the Senate was a provocative Iran sanctions bill introduced by Mr. Menendez and Senator Mark S. Kirk of Illinois, a Republican, over resistance from the White House.

Former Senator Robert G. Torricelli said Mr. Booker’s continued support was essential to his imperiled ally’s survival.

“It is enormously valuable to Bob Menendez, that Cory Booker — and the remainder of the caucus — remain loyal and await the legal judgment,” said Mr. Torricelli, a Democrat who abandoned his 2002 re-election bid amid an ethics investigation. (He was ultimately not charged with a crime.)

“This process may go on for months, if not years, and it’s important that Bob Menendez remain effective,” he added.

Veterans of New Jersey politics call the collaboration between Mr. Booker and Mr. Menendez a welcome departure from a tiresome pattern of hostility, going back more than a decade, between the state’s top political figures.

That animus has seemed to transcend individual personalities, enveloping lawmakers including Mr. Torricelli and Mr. Lautenberg, who famously feuded, but also dating back to Mr. Menendez’s frosty relationship with former Senator Bill Bradley. (When Mr. Bradley, a Democrat, ran for president in 2000, Mr. Menendez actively supported Vice President Al Gore.)

If anything can test the Booker-Menendez bond, it may be the long process of resolving a criminal case that has already grievously embarrassed Mr. Menendez, and could embarrass many more Democrats by association.

For now, State Senator Raymond J. Lesniak of New Jersey, a former state Democratic Party chairman, said the outbreak of civility was a welcome change from past practice.

“We here in New Jersey are used to our senators fighting each other, but the relationship between Menendez and Cory Booker has been a breath of fresh air,” Mr. Lesniak said.

A version of this article appears in print on , on Page A20 of the New York edition with the headline: Booker, Mentored by Menendez, Assumes Role as His Defender During Legal Fight. Order Reprints | Today’s Paper | Subscribe