Police said the toddler was struck by a Honda Civic in Charnwood Place on Friday evening.
Emergency services were called at around 6.50pm and the child was taken to Dumfries and Galloway Royal Infirmary, where he was pronounced dead shortly afterwards.
The 54-year-old man driving the car was uninjured.
Sergeant Bob McNay, from Police Scotland’s road policing unit, said: “Our thoughts are with the child’s family at this time, following their tragic loss.
“The investigation into the incident is ongoing and we are asking for anyone who was in the area and witnessed the events to please come forward.
“We are also keen to speak to anyone who may have CCTV overlooking the Charnwood Place area to get in contact, as they may be able to assist our inquiries.
“If you have any information, please contact police on 101, quoting incident 3597 of April 2, 2021.”