To use in place of something else, with the same function.
I had no shallots so I substituted onion.
(in the phrase "substitute X for Y") To use X in place of Y.
I had to substitute new parts for the old ones.
(in the phrase "substitute X with/by Y") To use Y in place of X; to replace X with Y.
I had to substitute old parts with the new ones.
To remove (a player) from the field of play and bring on another in his place.
He was playing poorly and was substituted after twenty minutes
To serve as a replacement (for someone or something).