WASHINGTON — Senate Democrats on Tuesday blocked action on legislation that would ban almost all abortions after 20 weeks of pregnancy and impose criminal penalties on doctors who fail to aggressively treat babies born after abortions, casting a pair of votes that Republicans hope to use to their advantage in the 2020 elections.

The two measures, which both fell short of the 60 votes necessary to advance, were doomed from the start, having already failed in the Senate. But the action on Tuesday, scheduled by Senator Mitch McConnell, the majority leader, was engineered to energize social conservatives and put centrist Democrats facing tough re-election campaigns in a difficult spot with an issue that plays to deep cultural divides in the country.

“Today every senator will be able to take a clear moral stand,” Mr. McConnell, Republican of Kentucky, said, adding, “At a minimum, elective abortion should be limited to the first three months of pregnancy.”

The votes, which fell mostly along party lines, came as President Trump, who has taken to calling himself “the most pro-life president in American history,” is making opposition to abortion a central theme of his presidency and his campaign for re-election. The debate was emotional and highly charged, with Republicans repeatedly accusing Democrats of favoring killing babies — an assertion that has no basis in fact.