But the undertaking will not prevent any witnesses’ evidence from being used against companies in any future prosecution.
Lawyers from firms including the main contractor and architects involved in revamping the 24-storey tower in west London submitted the last-minute bid for the pledge when the inquiry reopened in January, causing proceedings to be delayed.
The Inquiry chaired by Sir Martin Moore-Bick will now resume on Monday.
The Attorney General Suella Braverman said she had concluded that the undertaking was needed to enable the Inquiry to continue to hear vital evidence about the circumstances and causes of the fire.
Without it, she has concluded that some witnesses would be likely to decline to give evidence.
She took into consideration all representations received including those from victims and their representatives. She also consulted the Director of Public Prosecutions, the Health and Safety Executive and the Metropolitan Police Service.
The Attorney General said: “In making this decision I have had the victims of the fire and their loved ones at the forefront of my mind.
“I cannot begin to imagine what they have gone through and I know that the issue of an undertaking will have caused them further anguish.
“The undertaking I am providing to the Inquiry means it can continue to take evidence from witnesses who otherwise would likely refuse to answer questions.
“These questions are important to finding out the truth about the circumstances of the fire. The undertaking will not jeopardise the police investigation or prospects of a future criminal prosecution.”