The synthesis of sildenafil citrate was first reported in the Bioorganic & Medicinal Chemistry Letters, Vol 6, pp. 1819, 1824, 1996. The reaction scheme is reproduced below. Sildenafil was reported in this journal as "a potent and selective inhibitor of type 5 PDE with utility for the treatment of male erectile dysfunction".

The first step of the synthesis is the reaction of a diketoester (1) and hydrazine to give the pyrazole ring. The regioselective N-methylation of the pyrazole and hydrolysis gives a carboxylic acid (3). Compound (3) is then reacted with HNO3 and H2SO4 to give a nitrated product.
This is then followed by a carboxamide formation and the reduction of the nitro group. The compound (4) is then acylated under basic conditions and this produces the pyrazolopyrimidinone (6). (6) is then chlorosulphonylated selectively on the 5'-position of the phenyl ring. This can then couple with an amine to give sildenafil (7).
The yield of each step is given on the reaction scheme.

This is the original synthesis which was reported in the literature when the molecule was first synthesised. A variant of the synthesis was published but the changes it involved only consisted in the change of a few reactants, and no major changes were reported. This synthesis appeared in the January 1999 issue of Chemistry in Britain. This journal only reported the original discovery synthesis and said that the synthesis used commercially had not been published.

The drug is commercially manufactured by an alternative route. The reaction scheme is described in the patent which was published on 17 decembre 1997. However, the synthesis used in the commercial manufacture could be different to this. The patent was filed by the Pfizer Research and Development Company. The scheme is reproduced below.

The synthesis was described in a lot of detail, including the solvents that were the best to use, however, these details have not been reproduced here. These and further details about the synthesis can be found on the original patent document.

The reaction pathway is explained in more detail below.
Compound 2 can be prepared by the chlorosulphonation of 2-ethoxybenzoic acid (1). The conversion of compound 2 to compound 4 is achieved by N-sulphonation of 1-methylpiperazine and may be conducted in a one or two step procedure. Coupling of compound 4 with compound 6 can be achieved by any of the known amide bond-forming reactions. The aminopyrazole (6) is obtainable by the conventional reduction of the corresponding nitropyrazole (5). The resulting solution of compound 6 may be used directly after filtration in the coupling reaction with compound 4.
The cyclisation of compound 7 to give sildenafil has been achieved in yields up to 95%. Thus the overall yield of sildenafil based on compound 1 as a starting material, depending on whether the one or two step sulphonylation procedure is used can be as high as 51.7% or 47.8% respectively. This compares favourably with the first synthesis in which the overall yield is 27.6%.
The cyclisation of compound 7 to sildenafil can be conducted under neutral or acidic conditions. Under neutral conditions, compound 7 is heated, optionally in the presence of a solvent and/or optionally in the presence of a dehydrating agent and/or mechanical water removal system. Under acidic conditions, the reaction is carried out with a prolic acid or Lewis acid optionally in the presence of a solvent.

The reagents employed in the reactions can vary, but the following are among the ones recommended by the submitters of the patent:
The first step is the chlorosulphonylation of 2-ethoxybenzoic acid. This can be achieved by reacting 1 equivalent mole of thionyl chloride with 4 equivalent mole of chlorosulphonic acid. Addition of 1-methylpiperazine to an aqueous suspension of compound 2 is a suitable reaction to obtain compound 4 in one step. The carboxylic function of compound 4 can be activated using a 5% excess of N,N'-carbonyldiimidazole in ethyl acetate. This intermediate can then be reacted with imidazolide and compound 6. Compound 6 is obtainable by reduction of the corresponding nitropyrazole 5 for example by using palladium catalysed hydrogenation in ethyl acetate. Compound 7 is then cyclised to complete the reaction scheme and give sildenafil.
Information about the synthesis used to manufatcure Viagra was not available, and the two presented above are only the ones which were published. It is not surprising that the commercial manufacture of the drug is by a pathway that is not published.