Wayne Barrett, an investigative journalist who pursued the deeds and misdeeds of New York City politicians and players during four decades with the Village Voice, died at age 71. (Chester Higgins Jr./New York Times)

Wayne Barrett, an investigative journalist who pursued the deeds and misdeeds of New York City politicians and players during four decades with the Village Voice, skewering mayors — and future president Donald Trump — with stories collected through the time-honored traditions of muckraking, died Jan. 19 at a hospital in Manhattan. He was 71.

He had interstitial lung disease, but the immediate cause was complications from pneumonia, said his wife, Fran Barrett.

Mr. Barrett was a journalistic institution in New York, where he was dreaded if not loathed by the same public officials who, in occasional unguarded moments, conceded a certain respect for his intellect and doggedness on the trail.

He dredged from the past such reports as the imprisonment at Sing Sing of Harold Giuliani, the father of former New York mayor and federal prosecutor Rudolph W. Giuliani, for the armed robbery of a milkman in 1934. In recent months, as Trump rose from tabloid staple, businessman and reality-television star to president of the United States, Mr. Barrett was recognized as perhaps the first reporter to have probed Trump’s life, his business dealings and his potential importance on the national stage.

He wrote for the Voice, a counterculture weekly with a reach that outpaces its modest circulation, from 1973 until he what he described in a New York Post column as his “sudden and involuntary end” amid budget woes in 2010. The New York Times called him “the junkyard dog of city political reporters who has drawn blood from generations of elected officials.”

“Our credo must be the exposure of the plunderers, the steerers, the wirepullers, the bosses, the brokers, the campaign givers and takers,” Mr. Barrett once said, accepting an award at Columbia Journalism School. “So I say: Stew, percolate, pester, track, burrow, besiege, confront, damage, level, care.”

Mr. Barrett began writing the Voice’s “Runnin’ Scared” column in 1978, the day that Edward I. Koch (D) became mayor of New York. (“He became mayor and I became his weekly tormentor,” Mr. Barrett later quipped.)

His reporting for the Voice fueled the publication of four books — one about contracting malfeasance during the Koch administration, one about Trump and two about Giuliani (R), whom Mr. Barrett derided as a “hero prosecutor” transformed into a “used 9/11 memorabilia salesman” — that established Mr. Barrett’s reputation far beyond the city’s five boroughs.

He profiled Trump in a Village Voice series in 1979 and wrote the book “Trump: The Deals and the Downfall” (1992).

“Nobody took him seriously when the book came out, so nobody was interested in reading it,” Mr. Barrett said ruefully in May 2016, days before Trump secured the number of delegates necessary to win the Republican presidential nomination. “It had a very short life.”

The book was rereleased in 2016 under the title “Trump: The Greatest Show on Earth.”

“He took Trump seriously as a public figure and approached him with an earnestness in his reporting,” Timothy L. O’Brien, a former research assistant to Mr. Barrett and the author of “TrumpNation: The Art of Being the Donald,” said in an interview. O’Brien described Mr. Barrett as the “godfather of everyone else’s coverage,” crediting him with drawing the first “map” of Trump’s family, his business operations, and their intersections with politics and New York life.

Mr. Barrett’s book provided a thorough look at Trump’s life to that point, from his early days in business when his father, Fred Trump, dispatched a lawyer to buy $3 million in gambling chips at a Trump casino that was about to go under.

Mr. Barrett unflatteringly documented Donald Trump’s sway in New York power circles and his mentorship by Roy Cohn, the defense lawyer and former aide to Joseph R. McCarthy (R-Wis.) during the disgraced senator’s Communist witch hunts.

“I have not read it, it’s a piece of fiction, it’s a very boring book,” Trump told Newsday in 1992. “Wayne is a very bad writer.”

After Trump began pursuing the White House in 2015, dozens of reporters covering his campaign called upon Mr. Barrett and the documentary archives that he housed in his basement in Brooklyn. As Trump was poised to take the Republican nomination, Mr. Barrett told CNN that he did not expect Trump to win.

When Trump ultimately triumphed, Mr. Barrett told the New Yorker from his sickbed, “Donald just has no interest in information. He has no genuine interest in policy. He operates by impulse. And I don’t see any of that changing. . . . Why would you change it? You got to be President of the United States.”

Wayne Richard Barrett was born in New Britain, Conn., on July 11, 1945, and grew up in Lynchburg, Va. His father was a nuclear physicist.

In his youth, Mr. Barrett espoused conservative politics, starting the Teenage Republicans of Lynchburg. He briefly attended a seminary before enrolling in St. Joseph’s University in Philadelphia, where he graduated in 1967, and where he wrote for the school newspaper. He said he was barred from a Jesuit honor society over editorials that were critical of the university’s administration.

“The dispute interested me, this whole notion that I should eat my words,” he told Newsday. “It also made me much more interested in journalism. I saw the power of it, I saw the effect of it, I saw that you could write something and it could shake up this community that I lived in.”

Mr. Barrett graduated in 1968 from Columbia Journalism School, where he was said to have moved leftward in his politics. He was a public school teacher and community organizer before beginning his career at the Voice.

His first book, written with fellow Village Voice journalist Jack Newfield, was “City for Sale: Ed Koch and the Betrayal of New York” (1988). “Here was this guy who we thought was a reformer,” Mr. Barrett told the public affairs program Democracy Now! of Koch, “who, I think, betrayed the reform movement in very fundamental ways.”

Mr. Barrett had a complicated relationship with Giuliani, whom he said he admired when Giuliani was a U.S. attorney in the 1980s.

“I identified with him a great deal in some ways. We both did 16 years of Catholic school, we’re a year apart in age, we both chased the same bad guys,” Mr. Barrett told the Times in 2000. After Giuliani became mayor in 1994, Mr. Barrett said that he observed a change in him, which he documented in the book “Rudy! An Investigative Biography of Rudolph Giuliani” (2000), written with the assistance of Adam Fifield.

“The arrogance that is like body odor to Rudy,” Mr. Barrett wrote, “repellent to others but undetectable to him, is rooted, strangely enough, in his concept of clean hands. He is never wrong, his swagger says, because he has spent his life uncovering and combating wrong, a knight besieged but un-daunted by the compromised, confused and corrupt.”

In the book, Mr. Barrett looked into the criminal activity of the mayor’s family, cast doubt on his charisma as a prosecutor, criticized him over his record on race relations, and examined his marital infidelities.

“It is an amazingly well-researched exposé of Giuliani’s entire life, from his Brooklyn and Long Island childhood to his career as a federal prosecutor to the political machinations of his mayoralty,” wrote Michael Grunwald, a reviewer for the New Republic. “It is also, unfortunately, a horribly written paleo-liberal screed, full of vaporous pronouncements that sound like Wide World of Sports voice-overs: ‘Boldness was his birthright, destiny his dream.’ ”

In his book “Grand Illusion: The Untold Story of Rudy Giuliani and 9/11” (2006), Mr. Barrett and co-author Dan Collins savaged Giuliani’s leadership during the terrorist attacks of Sept. 11, 2001, which vaulted Giuliani to national prominence as “America’s mayor” and formed the foundation of his subsequent unsuccessful bids for the presidential nomination.

Rather than steady-handed leadership, they wrote, Giuliani displayed shortsightedness in his preparations for a potential attack and mismanagement when the attack came.

Mr. Barrett became a fellow at the Nation Institute after leaving the Village Voice.

In 1969, he married Frances McGettigan. Besides his wife, survivors include their son, Mac Barrett, both of Brooklyn; and several brothers and sisters.

Speaking to the New Yorker the day after Trump’s presidential win, he said he could scarcely accept the admonition by Hillary Clinton, the defeated Democratic nominee, that the country owed Trump “an open mind and a chance to lead.”

“I don’t know how you can look at the guy with an open mind and ignore everything he’s said and done up until now,” Mr. Barrett said. “You don’t look at him with an open mind; you look at him with all the information you can assemble, and you try to get him to not do the terrible things he promised.”