Famotidine is a well-known histamine H2-receptor antagonist and gastric acid secretion inhibitor. A key intermediate for the preparation of this compound is N-4-(cyanoethylthiomethyl)-2-thiazolyl!guanidine (also known as N-4-(2-cyanoethyl)-thio!methyl!-2-thiazoyl!guanidine). To prepare this intermediate U.S. Pat. Nos. 4,562,261 and 4,609,737 describe a route based on N-4-(chloromethyl)-4,5-dihydro-4-hydroxy-2-thiazolyl!-guanidine hydrochloride as the starting material. The synthesis involves preparing this starting material by portionwise addition of (aminoiminomethyl)thiourea to dichloroacetone in acetone at temperatures of about -5.degree. to -7.degree. C. and stirring the resultant mixture for 5 days at below 0.degree. C. The resultant N-4-(chloromethyl)-4,5-dihydro-4-hydroxy-2-thiazolyl!-guanidine hydrochloride is isolated, purified and converted to N-4-(2-aminoiminomethyl)thio!methyl!-2-thiazoyl!guanidine) dihydrochloride by reaction with thiourea. Without isolating this intermediate, the reaction mixture is cooled below 10.degree. C. and to the solution are added 3-chloropropionitrile and isopropyl alcohol, followed by dropwise addition of aqueous NaOH whereby crystals of N-4-(cyanoethylthiomethyl)-2-thiazolyl!guanidine are formed.