During his first campaign for the Senate in Texas, George H.W. Bush opposed the Civil Rights Act of 1964, the landmark law banning many forms of racial discrimination.

But four years later, as a member of the House, he voted for watershed legislation making it illegal to refuse to sell or rent housing on the basis of race.

When he ran for president two decades after that, Bush and his allies made an African American man convicted of murder and rape a central focus of his campaign’s effort to portray his opponent as weak on crime — stoking a controversy that reemerged in the racially charged atmosphere of this year’s midterm elections.

The nation’s 41st president, who died Friday at 94, had a complicated relationship with race during his long political career, which spanned the turbulent years of the civil rights movement, the war on drugs, a crackdown on violent crime and a contentious Supreme Court confirmation.

The son of a moderate Rockefeller Republican from New England, Bush entered the political arena in the South at a time when the GOP was deploying divisive tactics to appeal to white voters, and he embodied the dueling forces in the Republican Party’s decades-long struggle to appeal to a diversifying country.

President Trump’s overt attempts to capi­tal­ize on racial divisions have shifted the balance of power further away from voices preaching moderation and tolerance in today’s GOP. Bush’s legacy highlights other pivotal moments in the party’s fraught history on race.

“He was someone that we disagreed with quite a bit on important issues to the communities we serve,” said Hilary O. Shelton, director of the Washington Bureau of the NAACP. “But also someone where we were able to come to the White House and discuss many of those issues and concerns and get some things done as well.”

Bush’s father, Prescott Bush, was a moderate Republican senator from Connecticut who championed desegregation of schools and expanding civil rights. As a student at Yale University, George H.W. Bush started a chapter of the United Negro College Fund and helped to raise money for the scholarship program benefiting African American students.

He cut his teeth in politics in Texas during the 1960s, through involvement in the local Republican Party and then an attempt to unseat Democratic Sen. Ralph Yarborough in 1964.

In the campaign, Bush opposed the Civil Rights Act signed by President Lyndon B. Johnson, keeping in step with the GOP standard-bearer in that year’s presidential election, Sen. Barry Goldwater of Arizona.

“The new civil rights act was passed to protect 14 percent of the people. I’m also worried about the other 86 percent,” Bush said after the measure became law.

Johnson defeated Goldwater in a landslide that year. Bush lost to Yarborough.

After Goldwater’s wipeout, moderate Republicans were looking to move the party in a different direction and Bush started to fashion himself as a new kind of Republican, according to Jefferson Morley, a former Washington Post reporter who wrote a 1992 essay in the New York Review of Books tracing Bush’s attitudes on race over time.

“He was just trying to straddle a lot of the time,” said Morley, whose essay was titled “Bush and the Blacks: An Unknown Story.” Summing up Bush’s strategy on race throughout his career, Morley said: “Opportunistic is the word.”

By 1968, Bush was a member of the House and he faced another decision on far-reaching civil rights legislation. He voted in favor of the Fair Housing Act that prevented discrimination in home sales and rentals.

The bill was signed into law just days after the assassination of the Rev. Martin Luther King Jr., who advocated for ending housing discrimination.

Race would become an issue for Bush once again in 1988, when he ran for president. He was Ronald Reagan’s vice president in an era of heightened fears about violent crime.

In his campaign against Massachusetts Gov. Michael Dukakis (D), Bush emphasized a prison furlough program that Willie Horton, a convicted murderer, used to leave prison. About a year later while he was out, Horton, who is African American, raped a woman in Maryland and attacked her romantic partner.

A political organization aligned with Bush ran an ad that stands to this day as one of the most controversial in the history of modern politics. The narrator says that Dukakis “allowed first-degree murderers to have weekend passes from prison.” The spot goes on to show a black-and-white photo of Horton and provides details about his crimes.

“Weekend prison passes: Dukakis on crime,” the narrator concludes.

Critics have said the ad was a clear attempt at race baiting. “That was a deeply concerning and offensive campaign,” said Shelton.

Bush campaign manager Lee Atwater — who once said, “By the time we’re finished, they’re going to wonder whether Willie Horton is Dukakis’s running mate” — apologized for this tactic from his deathbed.

Mary Matalin, who served as one of Bush’s top political strategists, said the ad was not about race and noted that the campaign itself did not air the commercial.

“In decades of politics, I never met anyone, including Democrats, who had as many genuine African American friends as George and Barbara Bush,” Matalin wrote in an email. “Real friends with real history together. From all walks of life and never a political thing.”

During Bush’s presidency, his nomination of Clarence Thomas to the Supreme Court was another source of racial tension. In 1991, Bush selected Thomas to fill the seat of retiring Justice Thurgood Marshall, an iconic civil rights leader and the first African American to serve on the high court.

Thomas, who is also African American, faced criticism from civil rights organizations. In a lengthy statement explaining its opposition to Thomas, the NAACP cited his opposition to affirmative action, among other factors.

On other issues, Bush received plaudits for his record on race. “I found him to be an extraordinary man that preached love and values and principle and standards,” said William R. Harvey, the president of Hampton University.

Harvey served on a presidential advisory board on historically black colleges and universities that Bush created with an executive order. Harvey praised the strides in funding for those schools during Bush’s presidency.

In 1990, Bush vetoed a civil rights bill. Advocates of the measure argued it would help combat employment discrimination. The White House contended it would have incentivized “hiring and promotion quotas.”

The following year, Bush signed a scaled-back version of the legislation.