Elijah Cummings, who has died aged 68 after a long period of ill health, was a veteran congressman representing Baltimore, Maryland. In his final year he found himself engaged in a war of words with Donald Trump, when the president was the subject of his investigations as chairman of the House committee on oversight and government reform.

While Cummings’s committee investigated the proposed addition of a citizenship question to the US census, the use of private email by Trump officials and family, the machinations of the former Trump lawyer Michael Cohen and, most tellingly, the treatment of migrants on the Mexican border, Trump attacked Cummings on Twitter, accusing him of playing “the race card”.

The tweets culminated in one that told him to forget the border and concentrate on his own district, calling Baltimore a “rat and rodent infested mess where no human being would want to live”.

Cummings responded with a tweet informing the president that he went “home to his district daily. Each morning I wake up and I go out and fight for my neighbours.” He asked him to compare his district to the South Carolina one formerly represented by the Trump ally Mick Mulvaney, which was poorer and whose population was far less educated. The press was quick to point out that much of the rental property in Cummings’s district was owned by companies controlled by Trump’s son-in-law Jared Kushner.

Two weeks later, in a speech at the National Press Club, where his subject was racially motivated mass shootings, Cummings said: “Those at the highest levels of government must stop invoking fear, using racist language, and encouraging reprehensible behaviour. As a country, we must say ‘enough is enough’, that we are done with hateful rhetoric.”

Though this was seen as another sharp attack on the president, Cummings had a history of trying to cool racial violence. During the Cohen hearings, he stood up for the conservative Republican congressman Mark Meadows, who was accused of racism in his questioning, calling him “one of my best friends”. In 2015, he delivered the eulogy at the funeral of Freddie Gray, a black man killed in police custody in Baltimore. Hours later, as violence spread through the inner city, Cummings took to the street with a megaphone, asking residents to obey a police curfew, and telling them “I’d die for my people.”

He continued his message of cooperation at the 2016 Democratic national convention, when he spoke of the new civil rights movement, saying “our party does not just believe, but understands, that Black Lives Matter. But we also recognise that our community and our law enforcement work best when they work together.”

Cummings’s sense of justice came from his parents. Born in Baltimore, Elijah was the son of Robert Cummings and his wife, Ruth (nee Cochran). They had been sharecroppers in South Carolina before moving north to Maryland. Robert worked as a labourer, Ruth as a housekeeper, but both were preachers, and his mother found- ed the Victory Prayer chapel in Baltimore, which became a main- stay in the civil rights struggle.

Elijah grew up in a segregated city, recalling when he was 12 being stoned and beaten every day for a week as black people tried to use a swimming pool in a white area of the city. When his mother died, Cummings recalled her saying to him on her death bed: “Do not let them take our votes away.”

His parents also believed in education, because they had so little. Cummings was a graduate of Howard University, in Washington, then took a law degree at the University of Maryland. While working as an attorney, he served in the Maryland house of delegates (1983-96), becoming the state legislature’s first black speaker pro tempore.

In 1996 he was elected to Congress from Maryland’s seventh district, in a special election called when Kweisi Mfume resigned to become head of the National Association for the Advancement of Colored People. He first won a tightly contested Democratic primary, then went on to win the election with 81% of the vote. He was re-elected 12 times, once running unopposed, but with never less than 70%.

Far from being the caricature of urban blight portrayed by Trump, Cummings’s district includes mixed city neighbourhoods with elements of gentrification, as well as chunks of suburban Baltimore and adjoining Howard County.

Cummings was chair of the black congressional caucus in 2003-04, and was an early backer of Barack Obama’s run for the presidency in 2008, when he served as Maryland chair of the campaign. He was active in the progressive caucus as well, teaming up with Senator Elizabeth Warren on issues of healthcare, including lowering prescription drug prices. Cummings was one of the few Democrats to attend Trump’s inauguration; he reported that he and the president had had a friendly chat and found agreement about drug prices.

When the Democrats assumed control of the House of Representatives in 2018, Cummings, the senior majority member, became chair of the oversight committee. He was a close ally of Nancy Pelosi, the speaker, and his committee never jumped the gun on her eventual decision to pursue impeachment of the president.

With his first wife, Joyce Matthews, he had a daughter. The marriage ended in divorce, and he had a son and daughter from other relationships. In 2008, he married Maya Rockeymoore, a former congressional staffer who began a run for governor of Maryland in 2017, which she halted when Cummings underwent heart surgery. She is now chair of the Maryland Democratic party.

Cummings is survived by his wife and three children.

• Elijah Eugene Cummings, politician, born 18 January 1951; died 17 October 2019