Nearly every Republican and three Democrats voted to confirm Mr Barr, who will head the politically independent US Justice Department.
As the nation’s top law official, Mr Barr will oversee the special counsel’s Russia investigation.
Democrats were angered by his previous criticism of the Russia inquiry.
Mr Barr, 68, previously held the attorney general title from 1991 to 1993 under Republican President George H W Bush. He was a proponent of mass incarceration and similar tough-on-crime policies.
The well-known conservative lawyer had been working at the Kirkland & Ellis law firm in Washington DC prior to his nomination. He has also held posts at Verizon Communications, the CIA and in former President Ronald Reagan’s White House.
Democrats Doug Jones of Alabama, Joe Manchin of West Virginia and Kyrsten Sinema of Arizona voted in favour of Mr Barr – all three representing more conservative-leaning states.
Republican Rand Paul of Kentucky voted against Mr Trump’s pick, while North Carolina Republican Richard Burr did not vote.
How does this relate to the Russia probe?
As the new overseer of special counsel Robert Mueller’s Russia inquiry, Mr Barr will take the role back from Deputy Attorney General Rod Rosenstein, who was appointed when Mr Barr’s predecessor Jeff Sessions recused himself.
Mr Mueller’s investigation is looking into alleged Russian meddling in the 2016 election.
US media has reported that Mr Rosenstein plans to resign following Mr Barr’s confirmation.
During his confirmation hearings, Mr Barr called Mr Mueller a friend and rejected the president’s label of the inquiry as a “witch hunt”.
“I don’t believe Mr Mueller would be involved in a witch hunt,” he said.
When grilled by senators over whether he would protect the investigation, Mr Barr said Mr Mueller must be allowed to complete the probe and that he believes Russians “interfered or attempted to interfere in the election and we have to get to the bottom of it”.
But it is unclear how much of Mr Mueller’s final report Mr Barr will see fit to release.
Mr Mueller is required to present his findings to the attorney general, and Mr Barr must report to Congress when the investigation concludes and detail any plans Mr Mueller wanted to take that were not granted.
At his hearing, Mr Barr stopped short of committing to release Mr Mueller’s report, but promised as much transparency as possible.
Democrats have also been wary of Mr Barr over a memo he wrote prior to his nomination criticising Mr Mueller’s inquiry.
In it, Mr Barr contended that Mr Trump could not have obstructed justice by firing FBI director James Comey as such an action was within his constitutional rights.
In front of the Senate Judiciary Committee, he defended his decision to offer such a critique as “entirely proper”.
While Mr Barr said he would consult ethics officials on whether he would need to recuse himself from overseeing Mr Mueller because of the memo, he made clear the final decision would be his.
What’s the reaction?
White House Press Secretary Sarah Sanders called Mr Barr’s confirmation “a major victory for justice and the rule of law in America”.
Judiciary Committee member Democrat Dick Durbin of Illinois said though he respects Mr Barr, he fears the new attorney general’s views on the Russia inquiry, immigration and presidential power.
Calling Mr Barr’s confirmation “alarming”, Oregon Democrat Jeff Merkley slammed the memo as a “job application” to Mr Trump.
Senate Republicans meanwhile have praised Mr Barr’s political resume.
Following his confirmation, Senator Lindsey Graham said Mr Barr would be “a steady hand at a time of turmoil”.