TOPEKA, Kan. — The Republican-controlled Kansas House of Representatives voted narrowly on Monday to uphold Gov. Sam Brownback’s veto of a bill to expand Medicaid, ending a quest that came improbably close to succeeding in this deep red state despite Mr. Brownback’s unyielding opposition.

In spite of a torrent of phone calls and in-person pleas from constituents over the weekend, and last-minute lobbying by hospital leaders who said that expanding Medicaid would help save a number of rural hospitals from closing, the vote was 81 to 44, three short of the two-thirds majority needed for an override.

The effort to expand Medicaid to cover 150,000 additional low-income people in Kansas had been closely watched nationally, in part because it came just after President Trump and Republicans in Congress tried and failed to repeal the Affordable Care Act. Success might have provided momentum in some of the other 18 states that have not yet expanded Medicaid under the health law to cover far more low-income adults.