<PAGE>

                                                                    EXHIBIT 10.2
 
                           SHARE PURCHASE AGREEMENT
                           ------------------------

                               EXECUTED AS A DEED

                        BEFORE A COMMERCIAL STOCKBROKER

                           ("CORREDOR DE COMERCIO")

This agreement is entered into in Barcelona, on July 20, 1998


                                BY AND BETWEEN
                                --------------

ON THE FIRST PART: Persist, S.A, a company duly incorporated and existing under 
the laws of Spain, with registered office at Avda. Sofia 45-53 Local Commerical 
Torre 7, 08870 Sitges, Barcelona, and tax identification number A-60661295 
(hereinafter, the "PURCHASER"), duly represented herein by Mr. Abel Gerber
Mexas, by virtue of the powers that were specifically granted to him by the
Board of Directors of the Purchaser.

ON THE SECOND PART: Peritus Software Services, Inc., a company duly incorporated
and existing under laws of Massachusetts, with registered office at 2 Federal 
Street, Billerica, Massachusetts 01821, United States of America (hereinafter, 
the "SELLER"), duly represented herein by Mrs. Arancha Seva Garcia, by virtue of
a power of attorney granted before the public notary of Massachusetts, Ms. Linda
K. Boyle duly legalized by an Apostille pursuant to The Hague Convention of
October 5, 1961.

ON THE THIRD PART:  Solintec, S.A. a company duly incorporated and existing 
under the laws of Spain, with registered office at Sant Fruitos del Bages, 
Barcelona, Poligono Pla de Santa Ana, Parcela 8, and tax identification number 
A-60105129 (hereinafter, "SOLINTEC"), duly represented herein by Mr. Manuel 
Duenas Bailon, by virtue of the powers of attorney granted to him on December
28, 1995 before the notary public of Sabadell Mr. Maximo Catalan Pardo, number
5,545 of his files.

ON THE FOURTH PART: Mr. Abel Gerber Mexas, a US citizen, legal age, with address
at 12595 N. 88 Way, Scotsdale, Arizona, United States of America with passport
number Z6207896 (hereinafter, "MR. MEXAS"). Mr.Abel Gerber Mexas acts in his own
name and behalf.

The Purchaser and the Seller will be referred to collectively hereinafter for 
the purposes of this agreement as the "PARTIES".
<PAGE>
 
                                   RECITALS
                                   --------


I.     Whereas the Purchaser, is a Spanish Company incorporated on September 30,
       1994, before the Notary Public of Sant Feliu de Llobregat Mr. Jesus-
       Julian Fuentes Martinez, with number 990 of his files and is engaged in,
       among other activities, the maintenance of computer software and the
       consulting and auditing of programs.

II.    Whereas the Seller owns shares representing approximately sixty three
       point zero seven per cent (63.07%) of the capital of the Purchaser free
       of all liens, charges, options, encumbrances and claims; such percentage
       is represented by thirty thousand one hundred and fifty (30,150) shares,
       each with a par value of one thousand Pesetas (Ptas 1,000), of which
       1,900 are class A shares (numbers 1,201 to 2,500, 2,501 to 2,800, 3,201
       to 3,350 and 3,601 to 3,750), 2,700 are class B shares (numbers 1,301 to
       4,000) and 25,550 are class D shares (numbers 1 to 21,900 and 30,001 to
       33,650) (hereinafter, collectively, the "Shares" and each a "Share").

III.   Whereas the Purchaser is interested in purchasing and the Seller is
       interested in selling the Shares at the price and subject to the terms
       and conditions described below.

Therefore, the Parties hereto agree to enter into this sale and purchase 
agreement (hereinafter, the "Agreement") pursuant to the following


                                    CLAUSES
                                    -------

1.     PURCHASE AND SALE
       -----------------

1.1    PURCHASE AND SALE: Subject to the fulfilment of the condition precedent
       -----------------
       described in section 11 below, the Seller hereby sells to the Purchaser,
       who purchases, the Shares, free from any lien, encumbrance or third
       party's right.

1.2    DELIVERY OF POSSESSION: Subject to the fulfilment of the condition
       ----------------------
       precedent described in section 11 below, the Seller hereby delivers the
       possession of the Shares and transfers title thereof to the Purchaser by
       endorsing a global share certificate number 2 representing all the Shares
       to the Purchaser.

2.     PRICE AND METHOD OF PAYMENT
       ---------------------------

2.1    TOTAL PURCHASE PRICE: The total price to be paid by the Purchaser to the
       --------------------
       Seller for the Shares is U.S. dollars SIX HUNDRED THOUSAND (600,000)
       (hereinafter, the "Purchase Price"), that is, NINETEEN DOLLARS AND NINETY
       CENTS (US $19.90) per Share.

                                       2

<PAGE>
 
2.2    PAYMENT: The Purchaser will deliver to the Commercial Stockbroker for the
       -------
       benefit of the Seller a certified check ("cheque conformado") in the
       amount of U.S. dollars FOUR HUNDRED AND SEVENTY THOUSAND (470,000) not
       later than July 21, 1998, 2:00 p.m. (Barcelona time). Such amount is the
       result of deducting from the Purchase Price U.S. dollars ONE HUNDRED AND
       THIRTY THOUSAND (130,000) which the Seller owes to the Purchaser in
       relation to the so-called MicroAge Contract. The Parties sign
       simultaneously to the execution of this agreement a letter which is
       attached hereto as Annex 1 containing the final terms of settlement of
                          -------
       costs and expenses of Seller to Purchaser in connection with the MicroAge
       Contract.

3.     REPRESENTATIONS AND WARRANTIES OF THE SELLER
       --------------------------------------------

       The Seller hereby irrevocably represents and warrants as follows:

3.1    The Shares (i) have been validly issued; (ii) are fully paid-up; (iii)
       are freely transferable, other than as established in the Purchaser's by-
       laws; and (iv) are free of encumbrances, liens, pledges, burdens,
       attachments, third party's right or any other type of rights "in rem.

3.2    The Seller (i) has full legal title to the Shares sold under this
       Agreement; (ii) has no obligation to transfer the Shares to a third
       party, or to create any mortgage, pledge, lien, claim, charge or
       encumbrance in respect to the Shares; and (iii) has full right, power and
       authority to sell, transfer and deliver the Shares.

3.3    The execution and performance of this Agreement and the consummation of
       all transactions contemplated hereby by the Seller will not require any
       consent approval or notice and will not conflict with, or result in the
       breach or termination of, or constitute a default under, any contract,
       agreement or other instrument to which the Seller is a party or by which
       the Seller is bound.

4.     REPRESENTATIONS AND WARRANTIES OF THE PURCHASER
       -----------------------------------------------

       The Purchaser hereby irrevocably represents and warrants as follows:

4.1    The Purchaser has full right, power and authority to buy and acquire the 
       Shares.

4.2    The execution and performance of this Agreement and the consummation of
       all transactions contemplated hereby by the Purchaser will not require
       any consent approval or notice and will not conflict with, or result in
       the breach or termination of, or constitute a default under, any
       contract, agreement or other instrument to which the Purchaser is a party
       or by which the Purchaser is bound.

4.3    The Purchaser has been operated in the regular and ordinary course of 
       business for all periods prior to the purchase and sale of the Shares.

                                       3
<PAGE>
 
5.   WAIVER TO PREFERENTIAL ACQUISITION RIGHT
     ----------------------------------------

     Solintec and Mr. Mexas waive any preferential acquisition right that he may
     have pursuant to Article 10 of the Purchaser's by-laws as a result of the
     sale of the Shares from the Seller to the Purchaser.

6.   WAIVER TO ACTIONS
     -----------------

     The Seller has delivered to the Purchaser before the execution of this
     Agreement the resignation letters of the directors in the Purchaser
     appointed at the request or proposal of the Purchaser. Subject to the
     fulfilment of the condition precedent described in section 11 below, the
     management of such directors, as well as the management of any other
     present or former director of the Purchaser, is approved by the Parties and
     by Solintec and Mr. Mexas as shareholders representing all the capital of
     the Purchaser.

     In addition, subject to the fulfilment of the condition precedent described
     in section 11 below the Parties, Solintec and Mr. Mexas declare that with
     the execution of this Agreement and the letter relating to the MicroAge
     Contract which is being executed simultaneously, they do not have anything
     to claim from each other and, accordingly, they irrevocably and
     unconditionally renounce to any action that they could have, except for
     any action arising from the falseness or inaccuracy of the representations
     and warranties of clauses 3 and 4 of this Agreement.

7.   COSTS AND EXPENSES
     ------------------

     All costs and expenses incurred by the Parties arising from the
     preparation, execution and performance of this Agreement shall be borne by
     each Party in equal amounts.

8.   NOTICES
     -------

8.1  FORM: All notices between the Parties relating to or arising from this
     ----
     Agreement shall be made by mail recorded delivery service or by facsimile.
     If made by facsimile, the notices shall be deemed valid and binding,
     provided that the facsimiles are signed by an authorized officer of the
     Party giving the notice. No special code shall be required.

8.2  ADDRESSES: The Parties have designated the addresses indicated in the
     ---------
     heading of this Agreement as the valid addresses for the purpose of
     receiving notices.

8.3  CHANGE OF ADDRESSES: Any notice sent to the above referenced addresses will
     -------------------
     be deemed to be received by the addressee, except if prior to the sending
     of such notice the addressee had notified to the other Party a change of
     address or telefax numbers.

                                       4
<PAGE>
 
9.    MISCELLANEOUS
      -------------

9.1   AMENDMENTS: No variation of this Agreement shall be valid unless it is
      ----------
      made in writing and signed by or on behalf of each of the Parties,
      Solintec and Mr. Mexas.

9.2   WAIVERS: The failure to exercise or delay in exercising a right or remedy
      -------
      under this Agreement shall not be interpreted as a waiver of the right or
      remedy or a waiver of any other rights or remedies and no single or
      partial exercise of any right or remedy under this Agreement shall prevent
      any further exercise of that or of any other right or remedy.

9.3   PARTIAL INVALIDITY: The invalidity, illegality or unenforceability of any
      ------------------
      provision of this Agreement shall not affect or impair the continuation in
      force of the remainder of this Agreement. Furthermore, in lieu of any such
      invalid, illegal or unenforceable term or provision, the intent of the
      Parties, Solintec and Mr. Mexas is that there shall be added as a part of
      this Agreement a provision as similar in terms to such invalid or
      unenforceable provision as may be possible and be valid and enforceable.

9.4   LANGUAGE:  This Agreement is executed in English.
      --------

10.   GOVERNING LAW AND JURISDICTION
      ------------------------------

10.1  This Agreement shall be governed and construed in accordance with the laws
      of the Commonwealth of Massachusetts.

10.2  The Parties, expressly waiving their rights to their own forum, expressly
      and irrevocably submit to the courts of the cities of Barcelona, Spain,
      and Boston, MA USA, for any disputes arising from the interpretation,
      validity, or enforceability of this Agreement.

11.   CONDITION PRECEDENT
      -------------------

11.1  The effectiveness of this Agreement, the transfer of the Shares from the
      Seller to the Purchaser and the effectiveness of the MicroAge letter
      attached as Annex 1 are all subject in all respects to the Purchaser
      delivering to the Commercial Stockbroker Mr. Carlos Cuatrecasas for the
      benefit of the Seller a certified check ("cheque conformado") in the
      amount of U.S. Dollars FOUR HUNDRED SEVENTY THOUSAND (U.S. $470,000)
      not later than 2:00 p.m. (Barcelona time) of July 21, 1998.

11.2  If by such time and date, the Purchaser has not delivered the indicated
      amount by a certified check and in U.S. Dollars then the Parties, Mr.
      Mexas and Solintec irrevocably instruct the Commercial Stockbroker to:

      (i)   Return the property titles ("titulos de propiedad") and share 
      certificate number 2 ("titulo fisico multiple") representing the Shares to
      the Seller's representative;

                                       5
<PAGE>
 
     (ii)    Destroy the signed copies of this Agreement; and

     (iii)   Deliver to the Seller the minutes of the Shareholders' Meeting of
     the Purchaser dated July 15, 1998 together with any resignation letters,
     all of which are delivered to the Commercial Stockbroker in this act.

11.3 If, on the contrary, the condition precedent is fulfilled, then the
     Parties, Mr. Mexas and Solintec irrevocably instruct the Commercial
     Stockbroker to:

     (i)     Deliver the certified check to the Seller's representative;

     (ii)    Deliver to the representative of each of the Parties, Mr. Mexas and
     Solintec a signed and sealed copy of this Agreement;

     (iii)   Deliver to the Purchaser's representative the property titles and 
     share certificate number 2; and

     (iv)    Deliver to the Purchaser's representative the minutes of the
     Shareholders' Meeting of July 15, 1998 together with any resignation
     letters.

IN WITNESS WHEREOF, the Parties, Solintec and Mr. Mexas have caused this 
Agreement to be executed at the place and on the date indicated above.



Persist, S.A.                           Peritus Software Services, Inc.




/s/ Abel G. Mexas                       /s/ Arancha S. Garcia
---------------------------------       ---------------------------------------
Mr. Abel Gerber Mexas in the name       Mrs. Arancha Seva Garcia in the name 
and on behalf of Persist, S.A.          and on behalf of Peritus Software 
                                        Services, Inc.

                                       6


<PAGE>
 
For the purposes of clauses 5 and 6:         For the purposes of clauses 5 and 6



/s/ Abel Gerber                              /s/ Manuel Duenas
---------------------------------            -----------------------------------
Mr. Abel Gerber Mexas, in his own            Mr. Manuel Duenas Bailon in the 
name and behalf                              name and on behalf of Solintec, S.A



           With my intervention, in my presence and in the same act,

                              [SEAL APPEARS HERE]


                           /s/ D. Carlos Cuatrecasas 
                           -------------------------
                           D. Carlos Cuatrecasas   
                      Commerial Stockbroker of Barcelona
<PAGE>
 
                        PERITUS SOFTWARE SERVICES, INC.




                                 July 20, 1998

Persist S.A.
Avda, Sofia 45-53
08870 Sitges (Barcelona), Spain

Dear Sir or Madam:

     In connection with the transfer of Peritus Software Services Inc.'s shares 
in Persist S.A. to Persist S.A., we hereby agree as follows with respect to the 
final settlement of all expenses related to MicroAge:

     (i)   All MicroAge expenses payable or accrued for all periods prior to
           April 1, 1998, shall be satisfied by payment of $50,000 from Peritus
           to Persist;

     (ii)  All MicroAge expenses payable or accrued for the period from April 1,
           1998 through June 30, 1998 shall be satisfied by payment of $80,000
           from Peritus to Persist; and

     (iii) Commencing July 1, 1998, Peritus will pay all MicroAge expenses
           including salaries, office rent and telephone expenses accrued on or
           after that date, provided that Persist assists Peritus in the orderly
           transition of the MicroAge work, persons, office lease and telephone
           line currently administered by Persist.

     Please acknowledge your agreement by signing below.

                                                   Sincerely,

                                                   /s/ John MacPhee

                                                   John MacPhee
                                                   V.P. and Treasurer 


Agreed to by Persist S.A.
By: /s/ Abel Gerber Mexas
   ----------------------