An Outline of the History of Restriction on Ijtihad
Anyone intending to learn more about the intense bigotry of the followers of these four madhahib may refer to the chronicles pertaining to most of the years in Ibn al-Athir's al-Kamil. 
The author of Mu'jam al-buldan observes in the first volume, under the entry pertaining to Isfahan, page 373:
Destruction spread in Isfahan at this time and before it as a result of the prevalence of bigotry amongst the Shafi'is and the Hanafts and the unremitting wars between these two parties. Whenever one party gained ascendency, it plundered the quarters of the other and burnt them down and destroyed them, and no bond or treaty would restrain them. 
These civil disturbances, strifes, and bigotries were instrumental in shaping the policy of the caliphs in compelling the fuqaha' to restrict themselves to the opinions of the masha'ikh `as a mark of respect for them and for the sake of seeking blessing through them: The fuqaha' on their part accepted the caliphs' orders restricting the madhahib to four and invented reasons to justify it.
Of these reasons, as will be discussed shortly, is the [dogma of the] closure of the door of ijtihad after the period of the early masha'ikh. This step of theirs was in accordance with the adage (`The people follow the creed of their kings'). Al-Ghazali, as quoted by Mawlawi Shah Wali Allah in his book al-Insaf, has expressed this very well in the following words:
After the period of Rashidun Caliphs, the caliphate was undeservedly taken over by a group of people who had no knowledge of the ahkam. Therefore, they needed the collaboration of the fuqaha'. Some of them of the top rank fled when accosted for service, while others sought the nearness of the caliphs and wrote books on theology, polemics, and differences between the madhdhib, each according to favourable circumstances and available means. 
Among such fuqaha' we have mentioned Ibn al-Salah (d. 643/1245) earlier.
One can conclude from the statements of reliable historians mentioned here, i.e. Ibn al-Fuwati in al-Hawadith and al-Maqrizi in al-Khutat, that the restriction of the following to the four madhahib and the proscribing of adherence to any other madhhab took place during the middle of the 7th/13th century and without any religious basis to justify it. Rather, it came about as a result of the policy of some caliphs and was complied with by those who were affiliated with the rulers and caliphs or sought nearness to them, and those who strived to obtain the posts of judges, imams, scribes, secretaries, etc.
[The Mujtahids After the Limiting of the Madhahib:]
The most eminent among major scholars, free men seeking to deliver themselves from the servility of taqlid, have shown their independence throughout history and founded their own madhahib and issued their own fatwas, such as Imam Jar Allah Mahmud ibn `Umar al-Zamakhshari (d. 538/1143) and Imam Muhy al-Din Muhammad ibn `Ali ibn al-`Arabi (d. 638/1240), although they have been associated with one of the madhahib as per the demands of their respective times. Similarly Ahmad ibn Taymiyyah al-Hanbali (d. 728/1327) professed to be a Shafi`i, and so did many of his followers; but his fatwas, which are followed by the Wahhabis, do not accord with the views of any of the four madhahib and indicate his independent approach. Al-Dhahabi says about him: "He deserves to do ijtihad because all its requisites are present in him."