The government and Islamic hardliners on Monday signed an agreement to enforce sharia law in the northwestern Swat valley, said a provincial minister.