Flouting European judges over prisoner voting would risk international "anarchy", the government's chief law officer has warned.
Attorney General Dominic Grieve said sticking to international rules could be "irksome" at times. But it had been the "settled view" of British governments for centuries that such obligations should be met.
The intervention came in evidence to the parliamentary Joint Committee on prisoner voting. The MPs and peers are considering how to respond to a European Court of Human Rights ruling against the UK's blanket ban on convicted prisoners taking part in elections.
David Cameron has said that the idea of overturning the ban makes him "physically sick", and the Commons overwhelmingly rejected the prospect in an indicative vote.
The committee has been asked to consider three options for a draft bill: giving the vote to convicted prisoners serving up to six months, giving it to those serving up to four years or keeping the existing blanket ban.
Mr Grieve said parliament had the power to withdraw from the European Convention on Human Rights, or any other commitment.
"Many of these international legal obligations, they impose obligations on others which we think benefit the international order and indeed us," he said. But at the same time they may at times impose obligations on us.
"That obligation may at times be irksome. You can always withdraw from an obligation by leaving a treaty or denouncing it.
"But while you are adhering to it, it seems to me that one has to think very carefully about what the consequences are in deciding that you can cherrypick the obligations that you are going to accept.
"Whilst it may be perfectly possible to disregard them you are creating a degree of anarchy in the international order that you are trying to promote."
The Tory MP and QC - who personally argued the Government's case to the court - said it would be "no slight matter" to ignore the ruling.
"You can't expect to be able to get other countries to observe international legal obligations if you choose not to," he said.