you have not mentioned which phone you are using, but i found this step in XDA forum, and this seems to have solved it. Could you check if one of the solution helps you: xda-adm-unlock, check out the post #3 by maysider.
Here is the complete snip of the sollution from XDA:
so the BUG is "made by Samsung". Samsung just do not accept any
correct PIN or password (maybe because of "wrong" keyboard).
could anyone tell me how to remove the lock without wipe? thx
solution 1) just if you have debugging mode on then follow this
solution 2) just if you can change your keyboard for another (if you
are allowed when entering password)
solution 3) just if you have Samsung account, log into Samsung Dive >>
"unlock" (my case)
solution 4) no debuging mode + no keyboard solution + no samsung
account? >> just and only wipe through recovery or Google Device
Happy now, but I was lucky
SAMSUNG BUG in 100 %
Edit by Izzy: The link with "solution 1" proposes changes made with ADB, which require root access:
update system set value=0 where name='lock_pattern_autolock';
update secure set value=0 where name='lock_pattern_autolock';
update system set value=0 where name='lockscreen.lockedoutpermanently';
update secure set value=0 where name='lockscreen.lockedoutpermanently';
This will unset your device lock completely, as if you did not have defined any.