TEHRAN, Iran — A top Iranian diplomat has rejected Britain’s decision to give diplomatic protection to a British-Iranian woman who has been detained in Iran for nearly three years, saying it contravenes international law.

British officials have said that Iran has failed to meet international obligations in its treatment of the woman, Nazanin Zaghari-Ratcliffe, and offered her diplomatic protection this past week.

The British foreign secretary, Jeremy Hunt, said this meant that the country no longer regarded her case as simply a consular matter and had raised it to the level of a legal dispute between Britain and Iran.

But the Iranian ambassador to Britain, Hamid Baeidinejad, said in a post on Twitter on Friday that Iran did not regard Ms. Zaghari-Ratcliffe as British.