Like most of the countries of the Middle East , Lebanon was formed from the ruins of the Ottoman Empire at the close of World War I , with boundaries drawn by the whims of the conquering French and British armies and with little thought about ethnic and sectarian rivalries .