Combine tomatoes and onion in a large glass, ceramic, or stainless steel container; sprinkle with salt. Cover and let stand in a cool place overnight. Rinse tomatoes and onion several times in cold water; drain. Set aside.
Combine peppercorns, mustard seeds, allspice, celery seeds, red pepper, and lemon slices; tie loosely in a cheesecloth bag. Combine spice bag, vinegar, and sugar in a stainless steel stockpot; bring to a boil. Add reserved tomatoes and onion. Return to a boil. Reduce heat; simmer, uncovered, 10 minutes, stirring gently several times. Remove spice bag, and discard.
Pack tomatoes into hot sterilized jars; cover with syrup, leaving 1/2-inch headspace. Remove air bubbles. Cover with metal lids, and screw bands tight. Process in boiling-water bath for 10 minutes.