Joined by a mutual fondness for good cigars and a round of golf, they spent holidays together in the Dominican Republic, unwinding at a gated oceanfront resort where houses cost as much as $20 million.

Mr. Menendez, appearing more subdued than he had a day earlier when the charges were announced, spoke in a low voice outside the federal courthouse in Newark after Judge William H. Walls released him on his own recognizance.

“For nearly three years, the Justice Department has pursued allegations based on smears launched by political opponents trying to silence me,” the senator said. “Now that they have laid out their case, we will finally have an opportunity to respond, on the record, in court, with the facts.”

The charges stem from the senator’s friendship with Dr. Melgen, a wealthy Florida eye surgeon who prosecutors say became a personal and political ally to Mr. Menendez over the years. Dr. Melgen hurried to the senator’s side when Mr. Menendez’s mother died, flew him on his private jet and contributed hundreds of thousands of dollars to support Mr. Menendez and the national Democratic Party.

In return, prosecutors said in the indictment, Mr. Menendez tried to deliver a host of political favors.

He is accused of trying to pressure the Obama administration to change the Medicare reimbursement policy in a way that would generate more income for the surgeon. Prosecutors said the senator also promoted a port security deal in the Dominican Republic involving Dr. Melgen and helped the doctor’s girlfriends in other countries obtain travel visas to the United States.

Emails cited by prosecutors showed that Mr. Menendez’s office took it upon itself to help mediate the surgeon’s dispute with Medicare.

In one 2009 email, Mr. Menendez instructed a staff member to call Dr. Melgen immediately about “a Medicare problem we need to help him with.” Another email from a staff member noted that the office had been “working on the Melgen case every day.”

But Mr. Menendez’s lawyer, Abbe Lowell, maintained that true affection between two friends was the only factor guiding Mr. Menendez. “This was a real friendship and not a corrupt relationship,” he said.

Some of the old rapport between Mr. Menendez and Dr. Melgen re-emerged in their prehearing huddles, as they leaned toward each other with a smile and a nod.

But for the most part they ignored each other. Mr. Menendez stood stiffly, his hands clasped behind his back, as Mr. Lowell read a not guilty plea on his behalf. Judge Walls ordered Mr. Menendez to relinquish his personal passport, though he is still allowed to travel on Senate business using an official passport.

For his part, Dr. Melgen appeared not quite as crisp as his onetime beneficiary. Wearing a wrinkled suit, he watched as Judge Walls set a $1.5 million bond, secured by 10 percent cash and property. Dr. Melgen later left the courthouse without comment.

A prosecutor, Peter Koski, seemed to be commenting on the strength of his case when he said during the hearing that the government was “ready for trial at the earliest possible date.”

Mr. Lowell said: “Sure, they have had the case for three years. We have had it for one day.”

Judge Walls set a tentative July 13 trial date for both men.

After repeating his comments in Spanish outside the courthouse, Mr. Menendez wished a horde of reporters a happy Passover. Then he rushed through a barricaded walkway to a waiting car.

Correction:

An earlier version of this article misquoted Senator Robert Menendez in a comment about federal charges against him. He said his team would “finally have an opportunity to respond, on the record, in court, with the facts,” not “probably.”

A version of this article appears in print on , on Page A15 of the New York edition with the headline: Menendez Pleads Not Guilty to Bribery Accusations. Order Reprints | Today’s Paper | Subscribe