Documents released in a lawsuit attempting to block the inclusion of a question about citizenship in the 2020 census show lobbying by anti-immigration hard-liners for the question’s inclusion, and resistance on the part of some census officials to asking it.

The Kansas secretary of state, Kris W. Kobach, who has taken a strong position against illegal immigration and was appointed by President Trump to a now-defunct panel on voter fraud, had advocated to include the question directly with the secretary of commerce, Wilbur Ross, according to the documents. In a July 2017 email to an aide to Mr. Ross, Mr. Kobach said that he had reached out to the secretary a few months earlier “on the direction of Steve Bannon,” then the White House chief strategist.

In an email to Mr. Ross, Mr. Kobach urged the addition of the question, saying that including undocumented immigrants in the decennial count of the United States population would, among other things, lead to the problem “that aliens who do not actually ‘reside’ in the United States are still counted for congressional apportionment purposes.”

The documents were released by the Justice Department late Friday night in response to a federal lawsuit from the attorneys general of 18 states aimed at blocking the inclusion of the question, which was added to the census questionnaire in March.