A confident and combative Rupert Murdoch testified Wednesday at a press ethics inquiry at the Royal Courts of Justice, where he emphatically denied suggestions he had ever asked for or received government favors for his media empire.

During his four-hour appearance before the panel, the News Corp. chief did, however, acknowledge close contacts with several high-ranking officials.

Murdoch is arguably the most highly anticipated of the 266 witnesses to have appeared before the Leveson Inquiry, which Prime Minister David Cameron set up in July amid a phone-hacking scandal at one of the media titan’s tabloids. And his testimony did not disappoint, offering concrete details about his ties with politicians during his long tenure at the center of British life.

There was the time in 2008, for instance, when Cameron, then the opposition leader, was flown by Murdoch’s son-in-law to a Greek island, where he joined Murdoch for drinks on a yacht.

Asked whether such behavior was normal, Murdoch said that politicians of all stripes “go out of their way to impress people in the press,” adding: “That’s part of the democratic process. . . . That’s the game.”

Murdoch acknowledged “flirtation” with Tony Blair even before Blair became prime minister in 1997. But he stressed, by loudly thumping the table, that “in 10 years of his power there, I never asked Mr. Blair for anything. Nor, indeed, did I receive any favors.”

At one point, Murdoch appeared to lose patience with Robert Jay, the inquiry’s lead lawyer, saying, “I don’t know how many times I have to state to you, Mr. Jay, that I never took commercial considerations” into account in his relationships with politicians.

Meanwhile, evidence emerging from Murdoch’s son James’s session before the panel the day before claimed a political scalp Wednesday when an aide to Culture Secretary Jeremy Hunt announced his resignation. The government’s culture office has been accused of trying to smooth the way for News Corp.’s takeover of Britain’s largest pay-TV provider.

The elder Murdoch is chairman and chief executive of News Corp., the world’s second-largest media conglomerate. Its U.S. companies include Fox Television, Fox News, the New York Post and the Wall Street Journal.

Asked about the phone-hacking scandal that led to the closure last year of his News of the World, a paper he bought more than 40 years ago, Murdoch said that illegally intercepting voice mails and using private investigators were marks of “lazy” journalism.

Before the scandal, which continues to engulf News Corp. — there are three ongoing police investigations — British politicians openly courted Murdoch. Cameron told the House of Commons on Wednesday that “we all did too much cozying up to Rupert Murdoch.”

That’s not to say the interactions were always positive. Murdoch described a testy call when then-Prime Minister Gordon Brown declared “war” on his company after the Sun newspaper decided to throw its support behind Brown’s rivals in the 2010 general election.

According to Murdoch, Brown said, “Well, your company has declared war on my government, and we have no alternative but to make war on your company.”

“I did not think he was in a very balanced state of mind,” Murdoch said Wednesday.

While Murdoch denied meddling with editorial decisions at the Times, the Sunday Times and the News of the World, he said the Sun’s editorials did reflect his thinking.

“I’m a curious person who is interested in the great issues of the day, and I’m not good at holding my tongue,” he said.

“He was defiant today,” said Tom Watson, a Labor member of Parliament and co-author of “Dial M for Murdoch,” a book about the hacking scandal. Watson said he expected that Murdoch’s testimony Thursday would reveal even more about his links to politicians.

“What we had today was a Day One scene setter,” Watson said.