WASHINGTON—The House voted Wednesday to block an effort to impeach President Trump, but the tally made clear that many Democrats are eager to pursue removing him from office despite party leaders’ calls for caution.

In the first test of the divisive issue since Democrats took control of the chamber, lawmakers voted 332 to 95 to kill the resolution, with all votes against the measure coming from Democrats.

House...