In terms of system linguistics, the lexicon of a language is an ideal entity that comprises the entire significative system of a language, under any aspect, to the extent that it is idiosyncratic rather than regular. The same would be true for an ideal dictionary, a perceptible representation of an ideal lexicon.
Real dictionaries are limited in their purpose and scope. Therefore, a dictionary is a representation of part of the lexicon of a language for a certain purpose. The following aspects are relevant here:
Given the complementarity between lexicon and grammar, a dictionary of a language is commonly accompanied by a grammatical description, or ‘grammar’ for short, that represents the grammar, i.e. the grammatical system of a language. The theoretical delimitation problem mentioned above then repeats itself at the level of the description. For instance, the paradigms of conjugation classes are shown in many dictionaries, but they are also contained in many grammars.
A dictionary contains linguistic knowledge, not world knowledge. The latter is the task of an encyclopedia. Nevertheless, delimitation between a dictionary and an encyclopedia is often problematic, as much of our world knowledge is coded in our language system. Most every kind of information in the world can be organized in the form of a (mostly alphabetic) list of items under which the information is grouped. There are, e.g., lexica of mythology, of ancient philosophers and of French cuisine. All of these are encyclopedias rather than dictionaries. More on this in ‘Dictionary vs. encyclopedia’.
The Neo-Latin word dictionarius is a calque on the Greek lexikón. Just as the latter is derived from the noun léxis ‘expression, saying, word’, so the former is derived, by the suffix -arius ‘repository of’, from dictio ‘expression, saying, word’. However, nowadays the words lexicon and dictionary are no longer synonymous, as explained above.