The next census will ask Scots about their "trans status" after MSPs approved changes to legislation on Thursday.
The amendment made to the Census Bill means that the 2021 census can include questions on transgender status as well as sexuality.
The exact text of the questions, which will be voluntary, is to be determined at a later stage.
The amendment was introduced by Scotland's culture secretary Fiona Hyslop to "address the issue of the perceived conflation of sex and gender", The Times reports.
She told Holyrood's culture committee, "There's currently limited evidence on the experiences of transgender people in Scotland and currently no fully tested question with which to collect information."
At present, only questions around religious affiliation are voluntary in the census.
According to The Scotsman, Hyslop told the committee: "The question on transgender status and history is voluntary and it is vital that nobody feels in any way compelled to answer the question. It is right it should be voluntary and that means there is no penalty in not answering."
The Scottish Government originally wanted the census to ask people about their "sex, including gender identity" but this was changed after being deemed confusing.
SNP MSP Joan McAlpine told The Times that questions in the census should "adhere to the principle that sex and gender identity should be kept completely separate".