Sen. Robert Menendez, a Democrat from New Jersey, center, and his daughter Alicia Menendez, left, exit federal court in Newark, New Jersey, U.S., on Wednesday, Sept. 6, 2017. (Louis Lanzano/Bloomberg)

The bribery trial of Sen. Robert Menendez began Wednesday with a federal prosecutor charging that the lawmaker sold his office in exchange for luxury getaways, private jet flights and hundreds of thousands of dollars in campaign cash.

“This is what bribery looks like,’’ said Assistant U.S. Attorney Peter Koski in opening arguments at U.S. District Court in Newark. “These two defendants corrupted one of the most powerful offices in our country. The defendants didn’t just trade money for power, they also tried to cover it up.’’

Menendez (D-N.J.) is accused of receiving gifts from Salomon Melgen, a doctor in West Palm Beach, in exchange for a range of government favors involving the doctor’s professional and personal life.

The two men have spent years fighting the charges, saying their trips together were evidence only of their public friendship, not secret crimes.

Supporters of the senator applauded as he walked into the courthouse to face trial on 12 separate charges.

“Not once have I dishonored my public office,” Menendez said.

He became emotional and choked back tears as he thanked his children and supporters who “have stood by me as I try to clear my name.’’

The courtroom of Judge William Walls was filled for opening arguments, as was a second, overflow courtroom.

Menendez’s lawyer, Abbe D. Lowell, accused the Justice Department of trying to paint a decades-long friendship as something sinister and criminal.

“It is wrong for a public official to violate the public trust, but it’s equally wrong for an innocent man to be charged,’’ he said. “The evidence will be that Bob Menendez and Sal Melgen have a real friendship.’’

Lowell said the prosecutors are focused on seven years of alleged corruption, but the relationship between the two men goes back to the early 1990s — proving their friendship is genuine. “Acting out of friendship is not improper, it is not corrupt, and it is certainly not a crime,’’ Lowell said.

Koski, the prosecutor, derided that claim.

“There’s no friendship exception to bribery,’’ Koski said.

Prosecutors allege Menendez repeatedly pulled strings to help Melgen in a variety of areas: in getting his girlfriends U.S. visas, in trying to resolve the doctor’s $8.9 million billing dispute with Medicare, and in an effort to help Melgen’s efforts to make money from a port security contract in the Dominican Republic.

“Senator Menendez went to bat for Doctor Melgen at the highest levels of our federal government over the course of many years . . . because Melgen gave Menendez access to a lifestyle that reads like a travel brochure for the rich and famous,’’ Koski said.

“Make no mistake about it — Robert Menendez was Salomon Melgen’s personal United States senator.’’

Prosecutors say they can tie $750,000 worth of campaign cash from Melgen to Menendez’s favors.

Since his indictment two years ago, Menendez has seen his political star dim, but he still has plenty of allies in the Democratic Party. Sen. Cory Booker (D-N.J.) attended the opening argument, and the two senators laughed and chatted during a court break.

Menendez has said he plans to attend the trial every day, but if a critical vote came to the Senate floor during the trial, he would consider leaving if his vote was needed.

Melgen’s lawyer, Kirk Ogrosky, attacked prosecutors for what he called their “filthy, dirty view of the world’’ and urged jurors not to be so jaded.

The defendants are “not guilty and they stand falsely accused,’’ said Ogrosky. “What you’re going to hear from every single witness who knows these two men is that they are friends. Real friends.’’

He also said prosecutors would try to make his married client look bad by calling his former girlfriends to the witness stand — but urged the panel to focus on the facts. “These people want to trot these girlfriends here in front of you,’’ he said. “You’re not here to judge his personal life. I’m here to tell you right now that he’s not always the best husband.’’

The trial is expected to last nearly two months, but tempers were running high even before the jury entered the courtroom, during a couple of tense exchanges between Menendez’s lawyers and the judge.

When defense lawyer Raymond Brown argued that the judge had disparaged their case, the judge grew exasperated.

“Shut up for a moment,’’ the judge said.

“Excuse me, sir?” the lawyer replied.

Walls told the lawyer he felt “quasi-insulted’’ by the lawyer’s suggestion that a judge’s response was too critical of the defense.

The judge got testy again when Lowell defended another filing that the defense had made before opening arguments.

Lowell insisted they’d only made the filing to adhere to a previous instruction from the judge. “Fine. Bill me,’’ the judge shot back.