Only hours after the Rev. Martin Luther King Jr.’s assassination in Memphis on April 4, 1968, President Lyndon B. Johnson began calculating how to use the nation’s shock, grief and anger to push a major civil rights law through a racist Congress.

As riots erupted in Washington and dozens of other cities across the country, Johnson “seized upon the regrets over King’s assassination” to pressure the House and Senate to pass the Fair Housing Act, historian Robert Dallek said in an interview.

As a former Senate majority leader, “he understood the mood, the atmosphere in which he was always operating in relation to Congress,” said Dallek, who wrote the biography “Flawed Giant: Lyndon Johnson and His Times, 1961-1973.” “The assassination gave him an entering wedge, which allowed the 1968 law. It was an opportunity to get that passed. He had a masterful sense of timing.”

Johnson had signed the Civil Rights Act of 1964 and orchestrated passage of the landmark Voting Rights Act of 1965, which he believed was his greatest accomplishment, according to an account of his presidency created by the National Park Service.

Just five days before King’s assassination, Johnson, tainted by the Vietnam War, had stunned the nation by announcing that he would not seek reelection.

Still, there was much he wanted to accomplish, Dallek said.

Johnson, who had grown up poor in Texas, possessed a passion for redressing inequality and wanted to go down in history as a champion of civil rights.

“By the time he got to the Fair Housing Act,” Dallek said, “he had a long record, including consumer rights, voting rights, Medicare, consumer protection. It was a fulfillment of Roosevelt’s New Deal.”

Johnson had seized on John F. Kennedy’s assassination to push for passage of the Civil Rights Act, which ended segregation in public institutions and prohibited discrimination in employment.

Most of Johnson’s aides counseled against it, President Obama said on the 50th anniversary of its passage in 2014. They argued that the legislation would anger Southern Democrats in Congress, and, if he passed the bill, it might disrupt his domestic agenda.

“And one particularly bold aide said he did not believe a president should spend his time and power on lost causes, however worthy they might be,” Obama said. “To which, it is said, President Johnson replied, ‘Well, what the hell’s the presidency for? What the hell’s the presidency for if not to fight for causes you believe in?’ ”

The Fair Housing Act was designed to protect people from discrimination when they were renting, buying or securing financing. The House passed the bill in 1966, and it then died in the Senate. Johnson pushed again the following year, but the bill languished in committee.

Conservatives in the House and Senate feared the law would open the way for black people to move into white neighborhoods, according to an account by the University of Minnesota Law Library, which archives documents on former vice president and senator Walter F. Mondale (D-Minn.).

“Most of the Senate was afraid to touch such an explosive issue,” the library reported, “but Sen. Mondale agreed to carry the legislation forward.”

In 1968, Mondale and Sen. Edward Brooke (R-Mass.), the only African American in the Senate,  sponsored the Fair Housing Act of 1968 as an amendment to the pending civil rights bill.

On April 5, 1968, Johnson sent a letter to Speaker of the House John W. McCormack (D-Mass.), urging immediate action.

“Congressional leaders said that Dr. King’s murder could assure passage next week of a landmark civil rights bill,” Max Frankel wrote in a New York Times article that was published on April 6, 1968, with the headline “Johnson Asks a Joint Session of Congress; President Grave; Sets Day of Mourning for Dr. King — Meets Rights Leaders.”

In the letter, Johnson implored Congress to “guarantee a basic American right — the right of a man to secure a home for his family regardless of the color of his skin,” according to the American Presidency Project at the University of California Santa Barbara, which archives presidential documents.

Johnson invoked King’s death, writing, “Last night America was shocked by a senseless act of violence. A man who devoted his life to the nonviolent achievement of rights that most Americans take for granted was killed by an assassin’s bullet.”

The tragedy should prompt “all good men to look deeply into their hearts,” Johnson said. “When the nation so urgently needs the healing balm of unity, a brutal wound on our conscience forces upon us all this question: What more can I do to achieve brotherhood and equality among all Americans?”

Johnson urged Congress to respond immediately by enacting “legislation so long delayed and so close to fulfillment.” He wanted the bill passed before King’s funeral in Atlanta.

Debate on the bill was heated. “Opponents called the bill ‘obnoxious,’ ‘discrimination in reverse’ and claimed that it was ‘robbing all Americans of their basic rights of private property,’ ” according to the University of Minnesota Law Library account.

But on April 10, 1968, the day after King’s funeral at Ebenezer Baptist Church in Atlanta, the House voted 250 to 171 to pass the Civil Rights Act of 1968.

“A cheer went up from the packed galleries and there was applause on the floor earlier as Speaker John W. McCormack of Massachusetts announced the 229-to-195 vote by which opponents of the bill were blocked from sending the bill to conference. After that, the final passage was a formality,” Marjorie Hunter wrote in the New York Times.

“Outside, still ringing the Capitol, were troops rushed to Washington last week to quell rioting that followed the slaying of the Rev. Martin Luther King Jr. last Thursday. The assassination of Dr. King appeared to have influenced the outcome, despite the insistence by civil rights supporters that the bill would have passed in any event.”

The Civil Rights Act of 1968 — better known as the Fair Housing Act — prohibited discrimination in housing based on race, color, religion and national origin by landlords, real estate companies, cities, insurance companies and lending institutions, including banks. It prohibited discrimination in advertising, zoning, construction and outlawed the practice of “redlining” and racial discrimination through “restrictive covenants and deeds.”

“Now the Negro families no longer suffer the humiliation of being turned away because of their race,” Johnson told the crowd in the East Room of the White House as he signed the bill into law on April 11, 1968. “It proclaims that fair housing for all — all human beings who live in this country — is now a part of the American way of life. We all know that the roots of injustice run deep. But violence cannot redress a solitary wrong, or remedy a single unfairness.”

Fifty years later, the country still struggles to live up to the law passed in the wake of King’s murder. But its passage remains remarkable — and a tribute to Johnson’s political savvy.

He reveled in the victory, saying, “This afternoon, as we gather here in this historic room in the White House, I think we can all take some heart that democracy’s work is being done. In the Civil Rights Act of 1968 America does move forward, and the bell of freedom rings out a little louder.”

Then he abruptly left the podium and sat at a desk in the East Room, took off his glasses and signed the Civil Rights Act of 1968 into law.

Read more Retropolis: