The defeat marks the third time that legislation to legalise assisted dying has been voted down in the last two decades.