import arcpy mxd = arcpy.mapping.MapDocument("path to mxd") lyr = arcpy.mapping.ListLayers(mxd, "layer name")[0] arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "some query") mxd.save() #If you don't want to save the selection to the existing MXD, try saving it to another file: mxd.saveACopy("path to new MXD")