William H. Gray III, a Pennsylvania congressman who became the nation’s highest-ranking African American elected official while serving in the U.S. House of Representatives and who later headed the United Negro College Fund, died July 1 in London. He was 71.

He collapsed while attending the Wimbledon tennis tournament with one of his sons. A family spokesman, William Epstein, said the cause of death was not immediately known.

Rep. Gray, the pastor of a prominent church in Philadelphia, was elected to Congress as a Democrat in 1978 and served as chairman of the House Budget Committee in the 1980s.

In 1989, he was elected majority whip, the No. 3 job in the House leadership and the highest position occupied by a black elected official up to that point. Rep. James E. Clyburn (D-S.C.) held the same post from 2007 to 2011. President Obama was elected in 2008.

The base for Rep. Gray’s community activism was the 5,000-member Bright Hope Baptist Church, which he took over after the death of his father in 1972. His grandfather had previously been the church’s pastor.

William H. Gray III became House majority whip in 1989, the highest position occupied by a black elected official up to that point. He also served as president of the United Negro College Fund. (2007 photo by Rusty Kennedy/ASSOCIATED PRESS)

After a failed a congressional primary bid in 1976, Rep. Gray ran two years later and unseated the 10-term Democratic incumbent, Robert N.C. Nix Sr.

By 1985, Rep. Gray had become the first African American chairman of the Budget Committee and helped guide congressional budgets to passage through the late 1980s. When a reporter from Fortune magazine asked what made him fit to lead the Budget Committee, the congressman casually replied, “Did you ever try to run a Baptist church?”

Rep. Gray was known for his ability to reach consensus with congressional members of all backgrounds, including conservatives from both parties.

“Most House members are content to solidify their constituency back home and preach to the converted,” former congressmanStephen J. Solarz (D-N.Y.), told Newsweek in 1985. “Bill Gray has the confidence in himself to reach out across political ideological lines to build coalitions.”

Former representative Jack Kemp (R-N.Y.) hailed Rep. Gray in 1985 as “one of the brightest stars of the Democratic Party” and added, “He’s got integrity.”

As Rep. Gray rose in the House leadership, he was said to be under consideration for the 1988 vice presidential nomination or as a potential Treasury secretary. But he grew increasingly discouraged by rollbacks of social advances made in the 1960s and 1970s. He was especially critical of the two versions of the Gramm-Rudman-Hollings Act, passed by Congress in 1985 and 1987.

Gramm-Rudman, as it was often known, was the first congressional bill to call for sequestrations — or automatic budget cuts — if Congress could not reach agreement on spending limits.

“It is horrendous public policy, violating the most fundamental principles of congressional responsibility and accountability, the precepts of economic policy and plain common sense,” Rep. Gray wrote in a New York Times op-ed in 1985. “It is likely to produce not a balanced budget but institutional disorder and budget stalemate.”

Midway through his seventh term in 1991, Rep. Gray abruptly resigned from Congress to become president of the United Negro College Fund, which he described as “a higher calling” than elective office.

Congressional observers were mystified, and rumors circulated that he was the subject of federal investigations of financial improprieties. Rep. Gray’s supporters contended that he was being smeared by political attacks from opponents. He was never charged with wrongdoing.

Soon after taking over the United Negro College Fund, which supports scholarship programs for African American students and more than three dozen private historically black colleges, Rep. Gray moved its headquarters from New York City to Fairfax County.

In 1999, he secured a $1 billion pledge from software mogul Bill Gates for scholarships to be administered by the fund, believed to be the largest single act of philanthropy in the history of American higher education. By the time he retired, Rep. Gray had raised more than $1.5 billion for the college fund.

His “Midas touch for fund raising,” the publication Black Issues in Higher Education noted, “propelled the UNCF from a modest charity into the nation’s wealthiest Black nonprofit — one that outstrips even such well-known groups as the NAACP and the Urban League.”

William Herbert Gray III was born Aug. 20, 1941, in Baton Rouge. His father served as the president of two colleges in Florida before moving the family to Philadelphia in 1949.

Rep. Gray was a 1963 graduate of Franklin & Marshall College in Lancaster, Pa., and received a master of divinity degree in 1966 from the theological school at Drew University in Madison, N.J. He received a master of theology degree from Princeton University in 1970.

He was a pastor in Montclair, N.J., and taught at colleges in New Jersey and Philadelphia in the 1960s and early 1970s. Throughout his years in Congress, Rep. Gray often returned to his church in north Philadelphia to preach on Sundays.

In 1994, President Bill Clinton named Rep. Gray a special adviser to help oversee elections in Haiti. He later worked for several District-based lobbying firms, including his own company, Gray Global Advisors. He moved in recent years from Vienna to Coral Gables, Fla.

Survivors include his wife of 42 years, Andrea Dash Gray, and his mother, Hazel Yates Gray, both of Coral Gables; three sons, William H. Gray IV, Justin Y. Gray and Andrew D. Gray; and two grandchildren.

Rep. Gray was close to many leaders of the civil rights movement, including the Rev. Martin Luther King Jr., and sometimes was forcefully reminded of the social struggles faced by African Americans. In 1985, when Rep. Gray was House Budget Committee chairman, he and another black congressman were accosted by an armed guard who demanded to know what they were doing in the House parking garage.

“When I think of the indignities my parents bore, we’ve come a long way, but we still have a long way to go,” Rep. Gray told The Washington Post soon afterward. “My job as a black man is to knock down as many of those barriers as possible.”