The president who declared “the battle between democracy and autocracy” to be the defining struggle of his time has concluded that he needs to accept some imperfect but important friends.