WASHINGTON — The Senate has rejected legislation designed to ban abortions after 20 weeks of pregnancy.

But the bill succeeded at putting vulnerable Democrats on the record on that issue, which was one of the Republicans’ goals. The GOP is defending its 51-49 majority in the midterm elections.

Three Democratic-senators up for re-election in conservative states voted to advance the legislation. They are Sens. Bob Casey of Pennsylvania, Joe Donnelly of Indiana and Joe Manchin of West Virginia. Republican Sens. Susan Collins of Maine and Lisa Murkowski of Alaska voted with other Democrats to reject it.

The vote was 51-46, short of the 60-vote threshold to advance the bill.

The House passed identical legislation in October.